Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2016-01-29 21:13:50

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#14 2016-01-29 23:27:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

#16 2021-06-15 10:47:00

etc
Developer
Registered: 2010-11-11
Posts: 5,186
Website GitHub

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

Board footer

Powered by FluxBB