|
Full control over which Joomla template is used, and when:
- Use a different template for users on Internet Explorer, or mobile devices screenshot
- Use a different template for selected users, logged-in users and guests screenshot
- Switch to a different template at different times of the day screenshot
- Switch template based on front-end language or browser language screenshot
- Switch template for different components on your site screenshot, or different sub-pages of components (e.g. VirtueMart)
- Switch template for all menu items on a particular menu, or all “children” of a menu item screenshot
MetaTemplate Pro 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, and/or execute arbitrary PHP code.
Also available: MetaTemplate (free, download here) gives you the flexibility of MetaTemplate Pro, except that you have to code the rules in PHP (see FAQ). You still get the management interface, but none of the drop-downs and select boxes for built-in rules, mentioned above.
FAQ
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 module 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. MetaTemplate Pro and MetaTemplate change all that.
MetaTemplate Pro and MetaTemplate are built around the same rule engine. MetaTemplate has fewer form controls than MetaTemplate Pro (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 MetaTemplate with minimal modification.
MetaTemplate Pro 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 free 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.
MetaTemplate (and Pro) allows 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, MetaTemplate and MetaTemplate Pro 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 MetaTemplate 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 MetaTemplate to remember the new template for the rest of the session.
Here’s how to do it:
- 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.
- 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.
- 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 MetaTemplate will go on to the next rule.
- Create a new rule, and give it a name, e.g. “Continue Facebook Session”
- In this second rule, in the “Cookie/Session variable set?” drop-down, select “Session variable A”. In this way, if MetaTemplate 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.
- In this second rule, set the SUCCEED action to change the template to your target template.
- 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).
Screenshots (MetaTemplate Pro)
|