Auto Template Switcher

Version
1.0.1 (last update on Sep 24, 2008)
Rating
Compatibility
Votes
Favoured
51
License
GPLv2 or later
Non-Commercial
Type
Views
89619
Date Added
4 September 2008
For all other users using standard browsers (e.g. Mozilla, IE, Safari), they will see your default template.
I designed this initially to serve different templates for iPhone/iPod users. But you can use this for other browsers too, for example, if you wish to serve different templates for iMac, Windows and Linux users.
Important for Joomla 1.5 users !!!
==================================
You need to change one line in the Joomla Core for this to work:
In file /includes/application.php in function getTemplate (around line 281), change the line
if ($template = $this->get('setTemplate')) {
to this one
if ($template = $this->getUserState('setTemplate')) {
Latest Version
==============
v1.01 (for Joomla 1.0) and v1.51 (for Joomla 1.5)
Released September 23, 2008
In addition to switching template on different user agents, you can now also specify the inital designated page that will be displayed when a template-switch occurs. For example, you can automatically redirect an iPhone user to a dedicated iPhone home page when he or she comes to your site.
You can specify different url page corresponding to each template and user agent in the parameters page of the Module Manager.
Note that a redirect to the designated page will only occur when there's a template switch. If there's no swtich of template, there will be no redirect to the page.
Thanks to Wayne Geddings for suggesting the above enhancement.
Demo
====
To see the module in action,
1) Install the module
2) Publish it in a module position in your home page.
If you are using the standard Joomla installation with the standard templates, you can just try loading the home page using Mozilla, IE and iPhone. You will see your home page displayed in different templates.
If you have your customized templates, go to Modules Manager and
* Set the detect string for browser 1, 2 and 3
* Set the corresponding template for browser 1, 2 and 3
How it works?
=============
The module uses $_SERVER['HTTP_USER_AGENT'] to detect user's browser.
For example, the value returned by iPhone is:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_0 like Mac OS X; en-us) AppleWebKit/525.18.1(KHTML, like Gecko) Version/3.1.1 Mobile/5A345 Safari/525.20
The program uses preg_match(), so you only need to use a string in $_SERVER['HTTP_USER_AGENT'] that uniquely identifies the browser you want to identify. For this case, the detect string can be as simple as "iPhone".
The module allows you to specify up to 3 different browser user agents. For example, when you first installed the "Auto Template Switcher" module, the default settings are as follows:
Browser 1: iPhone
Browser 2: MSIE
Browser 3: Mozilla
For each browser, you specify the corresponding templates. The following shows the default settings when the module is first installed. The templates are
This module has saved me a ton of work. Because of Internet explorer’s non standard rendering of web content, the image in the header of my template did not show properly in its z-index.
Using KKsou's module allows me to keep the same design for both (FF & IE) browsers, but change the header image for each. It’s also a plus that I can also include 2 more templates in the mix if I need them.
KKsou went above and beyond in his support of this module when it did not work right out of the box. He responded to my forum post the same night and even emailed me. After checking a couple of things he realized that he forgot to include an instruction to edit application.php in the Joomla core and once I did that it worked perfectly. I am very grateful to KKsou for his commitment to producing high quality Joomla add-ons and I can't wait to try some of his other offerings.
Using KKsou's module allows me to keep the same design for both (FF & IE) browsers, but change the header image for each. It’s also a plus that I can also include 2 more templates in the mix if I need them.
KKsou went above and beyond in his support of this module when it did not work right out of the box. He responded to my forum post the same night and even emailed me. After checking a couple of things he realized that he forgot to include an instruction to edit application.php in the Joomla core and once I did that it worked perfectly. I am very grateful to KKsou for his commitment to producing high quality Joomla add-ons and I can't wait to try some of his other offerings.






