Chameleon: Control Joomla templates, menus & more

(52 votes, average 3.83 out of 5)

Introduction see more videos

Regain control over when different templates are used on your Joomla site, and which menu items are displayed:

  • Use a different template for users on Internet Explorer, or mobile devices screenshot
  • Use a different template/menu items for selected users, logged-in users and guests screenshot
  • Disable certain plugins on part of your site
  • Switch to a different template/menu at different times of the day screenshot
  • Switch template/menu items based on front-end language or browser language screenshot
  • Switch template/menu items for different components on your site screenshot
  • Switch template/menu items for different page types, cart contents, manufacturers and categories within VirtueMart screenshot
  • Switch template/menu items for all menu items on a particular menu, or all “children” of a menu item screenshot
  • Perform dynamic find-and-replace on your Joomla page screenshot

Video tutorials now available!

Chameleon is based on the same revolutionary rule engine as MetaMod.

If a rule succeeds, you can redirect to a certain page or URL, set cookies, disable certain menu items or plugins, change the site home page ("Default" menu item), change which menu item will be displayed as “Active”, add page titles/keywords/meta-descriptions, find and replace page text, set the page language, and/or execute arbitrary PHP code.

Also available: ChameleonLite (free, download here, Joomla 1.5 only) gives you the flexibility of Chameleon, except that you have to code the rules in PHP (see FAQ). You still get the management interface and succeed/fail actions, but none of the drop-downs and select boxes for built-in rules, mentioned above.

FAQ

Yes. From version 2.23, released 08 March 2012, Chameleon 2.23 works on both Joomla 1.7 and Joomla 2.5.
From version 2.30, released 25 February 2013, Chameleon works on both Joomla 2.5 and Joomla 3.0. The Joomla 1.7 support has been dropped from that release.
From version 2.33, released 6 August 2013, Chameleon works on Joomla 2.5-3.1.
From version 2.42, released 4 August 2014, Chameleon works on Joomla 2.5-3.3.

Note: the Joomla 1.5 version, and the Joomla 2.5-3.3 versions of Chameleon are separate products and must be purchased separately. This is because of the huge amount of work that it took to port Chameleon from Joomla 1.5 to 1.7, which resulted in a near rewrite of Chameleon.

Joomla allows you to set a default template for your site, then assign alternative templates to different menu items. That’s all. There’s no facility for assigning different templates to different groups of users (e.g. Registered/Author/Editor etc, or “non-logged-in” users). There’s no facility for assigning a template to particular articles, sections or categories, nor web domains, nor browser types.

There are good reasons to want to do all of these things. Joomla’s addiction to “Menu Items” makes it very difficult to achieve fine control over what template gets displayed when. Chameleon changes all that.

If you are using Joomla 2.5-3.3, there is no Lite version — only the full version is available.

Chameleon and ChameleonLite are built around the same rule engine. ChameleonLite has fewer form controls than Chameleon (e.g. it doesn’t have a form control for users or user groups) — the rest you have to code yourself in PHP. There’s a lot of help built in to the interface, and many MetaMod Recipes can be used for ChameleonLite with minimal modification.

Chameleon has some very useful rules built-in and is highly recommended. It’s much easier to configure (unless you’re a PHP genius of course, in which case grab the Lite version and enjoy!).

Rules are a way of describing what you want to happen on your site. In plain English, you might describe a situation this way:

  • “Whenever I am viewing an article in the News section, I want to use the specialist News template. I don’t care about which menu item we’re on”.
  • “Whenever someone views the site with Internet Explorer, they should see our specialist IE template. Mobile devices should use the Mobile template. All others should see the General template”.

The challenge is to make a way to put these rules together using form elements.

Chameleon (and the Lite version) allow you to create individual rules. Within each rule you can specify values for things like language, users, groups, browser types etc. In order for the rule to “Succeed”, every condition you specify within that rule has to succeed. If any of the conditions fail, then the end result of the rule is a “Fail”.

At the end of the rule (the Action), you specify what you want to happen for a Success or Failure. You can get the rule to immediately set a given template, or get it to fall through to the next rule. You can also get the rules to redirect to a certain page, set cookies, and/or execute some PHP code.

Using this system, you can create chains of rules that AND and OR together. If you can’t create the exact rule that you want, you have the opportunity to code it in PHP, which is an even more expressive language.

In the first rule, set the Action for Success to return the desired template. Set the Action for Failure to not change the template, and “Process next rule”.

In the second rule, do the same thing.

In this way, if the first rule does not succeed, the second one will be tried. If that does not succeed, then you can set an alternative Action, or just fall through and don’t change the template.

In the first rule, set the Action for Success to set the desired template, but “Process next rule”. Set the Action for Failure return an alternative template or to “Stop Processing”.

In the second rule, do the same thing.

In this way, the template will only be set if both the first and second rules Succeed.

No. However, Chameleon and ChameleonLite both have the ability to pick up the GET, POST, COOKIE or session variables set by most of the common front-end template switchers, and can take these into account in the rules. The option is named “Honour template set in session/cookies/GET/POST”. When this is set, if Chameleon detects one of these cookies then it sets the requested template as the default template, then continues processing the rules. The rules can override this template, or, by not setting their own template, the default will be passed through to Joomla and activated.

(available from v1.3). This is a common thing to want to do. e.g. you are checking the HTTP referrer, and you want to switch to a particular template if the browser is coming from your FaceBook page. Naturally, the referrer string is only http://www.facebook.com/some_page for the first page visited on your site – so you want Chameleon to remember the new template for the rest of the session.

Here’s how to do it:

  1. Set up your first rule to detect the referrer, and return true if it finds the facebook URL. Enter the referrer URL (e.g. http://www.facebook.com/some_page) into the “Referrer” box, and set the drop-down to “equals” or “starts with” as appropriate.
  2. In the Actions box, set the SUCCEED action to change the template to the one you want, then in the drop-down immediately below it, select “Set Session variable A”. This just sets a flag to pick up in your next rule.
  3. In the Actions box, set the FAIL action to leave the template as it is, but click the radio button for “process next rule”. In this way, if the referrer is not Facebook, then Chameleon will go on to the next rule.
  4. Create a new rule, and give it a name, e.g. “Continue Facebook Session”
  5. In this second rule, in the “Cookie/Session variable set?” drop-down, select “Session variable A”. In this way, if Chameleon detects that session variable A has already been set (i.e. the referrer was Facebook earlier in the session), then it will set this rule to SUCCEED, else it will set it to FAIL.
  6. In this second rule, set the SUCCEED action to change the template to your target template.
  7. That’s it.

If you use Permanent Cookie A-D instead of Session Variable A-D, then the template selection will be remembered on the visitor's web browser for up to 10 years, or less if they clear the cookies earlier. Remember to set this on both rules (setting it on the first one, and picking it up on the second).

The official manual is now available and contains full descriptions of all the forms and pages that are part of Chameleon and ChameleonLite.

MetaTemplate Pro and MetaTemplate were renamed to Chameleon and ChameleonLite in August 2011, to coincide with the release of the Joomla 1.7-compatible version.

The change was made because the product is capable of doing far more than just changing templates. It’s also capable of changing menu items on a page-by-page basis, changing which page is the home page, doing sophisticated redirections, and much more.

These other capabilities were being hidden because the name suggested that it was only about templates.

Screenshots (Chameleon)

Last Updated on Monday, 29 September 2014 23:19