Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: aam_if_host: Conditional Host Name Plugin
<txp:php>if (in_array($_SERVER["HTTP_HOST"], array('localhost', 'some.other.domain')):</txp:php>
do this
<txp:php>else:</txp:php:
do something else
<txp:php>endif</txp:php>
Something like that should be equivalent.
Offline
Re: aam_if_host: Conditional Host Name Plugin
A similar if not quite as precise approach is to set a site variable for the intended public_domain
then check if it matches txp:site_url
. Good, for example, for setting meta robots and preventing tracking on beta sites…
TXP Builders – finely-crafted code, design and txp
Offline
#15 2021-06-15 05:16:46
- gomedia
- Plugin Author
- Registered: 2008-06-01
- Posts: 1,373
Re: aam_if_host: Conditional Host Name Plugin
TXP 4.8 solution:
<txp:if_request name="HTTP_HOST" type="server" value="www.mydomain.com">
<!-- host is www.mydomain.com -->
<txp:else />
<!-- host IS NOT www.mydomain.com -->
</txp:if_request>
Offline
Re: aam_if_host: Conditional Host Name Plugin
And <txp:if_request name="HTTP_HOST" type="server" value="localhost, www.mydomain.com" match="any" />
for multiple hosts.
Online