Content last modified Tuesday 24 August 2021
hop to #bottom
Categories:
Author:
Current version:
0.10
About It:
Get it:
Rate it:
  • Helpful?
  • 1 Yes
  • 0 No
Flag it:

If you'd like to provide updated information and do not have access to directly edit, please contact the site admin; thanks!

aam_if_host

This little plugin is meant to help those who do Textpattern development on localhost or a subdomain. Sometimes you’ll want to do one thing on the in-development site, and another on the “live” site. The conditional tag provided by aam_if_host lets you do exactly that.

NOTE: requires Txp 4.0.4 or newer.

Usage

Let’s say you’re using some complex JavaScript on your site. On the public site you want to serve a script that’s been packed, but while you’re developing the site you want to keep the scripts readable for debugging. Here’s how:

<txp:aam_if_host name="localhost,dev.example.com">
  <script type="text/javascript" src="<txp:site_url />js/myscript.js"></script>
<txp:else />
  <script type="text/javascript" src="<txp:site_url />js/myscript.packed.js"></script>
</txp:aam_if_host>

The name attribute takes a comma-separated list of server names. The default value for name is “localhost”.

As with the built-in conditional tags, you can use <txp:else /> to specify what happens if the condition is false (e.g. the site is on www.example.com instead of localhost or dev.example.com).

License

Copyright © 2007 Adam Messinger.

Distributed under the terms of the BSD license.

Article Request Count:
Keywords/tags:
Initially released:
12/18/2007
Posted here:
18 Dec 2007

You know you want to visit the Archives.
Published with Textpattern