Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-18 08:51:00

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

aam_if_host: Conditional Host Name Plugin

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.

Download v0.10 (3.2 KB)

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.

Related Links

Last edited by Logoleptic (2007-12-25 02:42:18)

Offline

#2 2007-12-18 09:43:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: aam_if_host: Conditional Host Name Plugin

will be testing this one. Thanks.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2007-12-18 19:01:14

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: aam_if_host: Conditional Host Name Plugin

colak wrote:

will be testing this one. Thanks.

Thanks. Let me know if you run into any trouble with it.

Offline

#4 2007-12-19 01:53:06

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: aam_if_host: Conditional Host Name Plugin

I’ve updated the plugin with improved documentation.

If you’ve already downloaded the plugin, here’s the part I forgot to mention: the default value for the name attribute is “localhost”.

Offline

#5 2007-12-19 07:30:20

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: aam_if_host: Conditional Host Name Plugin

yep… Figured that one out:)

Working with it in my comp now on a very basic no other plugins install and seems to work just fine. I finally started to work on my own site… Knowing me, it’ll take a few months until i make the final decisions and put it online:) Your plugin is currently helping me to work with some conditionals I am thinking of including. The beauty of it of course is that if i forget any of it in the final upload, the code will still work as intended.

Last edited by colak (2007-12-19 07:31:46)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2007-12-19 09:27:30

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

Re: aam_if_host: Conditional Host Name Plugin

out of curiosity:
(how) does this differ from ied_if_domain ?

Offline

#7 2007-12-19 19:36:00

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: aam_if_host: Conditional Host Name Plugin

sthmtc wrote:

out of curiosity: (how) does this differ from ied_if_domain ?

Slightly different approaches to a similar problem. The ied_if_domain plugin parses a string from the tag’s domain attribute using regular expressions and compares it to the actual domain of the site. It’s great if your main concern is dealing with subdomains (like dev.example.com or blog.example.com) or testing to see whether or not you’re on a particular single domain or domain/subdomain combination.

The aam_if_host plugin turns a comma-separated list of host names from the name attribute into an array, then checks to see if the actual host is in that array. This is useful if you’re concerned about a handful of completely different domains — like localhost, testserver.net, and www.example.com — in addition to subdomains.

How this came up for me: I’ve recently been working with a client who owns a domain that they don’t use to host live sites, but just use for testing site changes and changes to their web application. I started by getting their site up and running on localhost, then it got moved to their testing domain, and then it went live on a third domain. This kind of staging process isn’t uncommon, so I decided to make a plugin that smooths things out a bit.

Last edited by Logoleptic (2007-12-19 19:55:24)

Offline

#8 2007-12-19 20:43:09

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

Re: aam_if_host: Conditional Host Name Plugin

thanks for the clarification! i’ve only used ied_if_domain to check for subdomains before but somehow had in mind that it would solve other issues as well :)
i’m in a similiar situation as you with your client. we’re using two domains, one for dev, the other obviously for live (it’s a different TLD and dev instead of www). that sort of staging process indeed makes up for a pretty good workflow and your plugin might come in very handy for me.

Offline

#9 2007-12-19 20:57:02

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: aam_if_host: Conditional Host Name Plugin

@sthmtc: Glad to hear the plugin might be useful for you. :-)

Offline

#10 2007-12-19 21:00:17

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: aam_if_host: Conditional Host Name Plugin

colak wrote:

Working with it in my comp now on a very basic no other plugins install and seems to work just fine.

Thanks for the update. I didn’t give this one as much testing as I usually like to before pushing it out the door, so it’s good to know that there aren’t any problems.

Offline

#11 2016-01-29 19:40:52

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: aam_if_host: Conditional Host Name Plugin

Does anyone have a backup of this plugin—either compiled or the source code?

The download link above has succumbed to 404 linkrot, and I can’t find it on Archive.org, Github, or Bitbucket.

Offline

#12 2016-01-29 21:12:22

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: aam_if_host: Conditional Host Name Plugin

I have a copy here.

Offline

Board footer

Powered by FluxBB