Howto dynamically switch default template for mobile device?

Everything to do with Joomla! 1.5 templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Locked
User avatar
jackrabbit
Joomla! Ace
Joomla! Ace
Posts: 1473
Joined: Thu May 21, 2009 3:12 am
Location: Florida
Contact:

Howto dynamically switch default template for mobile device?

Post by jackrabbit » Mon Apr 30, 2012 6:44 am

I have a script in my template to show different stylesheet to mobile devices but I want to entirely switch the default template to one specifically created for mobile phones.

Here is what I have tried in my default template. Note that this is just my idea of what I want to achieve
<?php defined( '_JEXEC' ) or die ( 'Restricted access' );
$template =& JFactory::getTemplate();

include_once './templates/devices.php';
$browser = new Browser();
if( $browser->getBrowser() == Browser::BROWSER_IPHONE) {
$template = ('mobile');
} else {
show joomla default template for desktop
}

It seems the detection really should be done in index2.php but that only caused errors. Please suggest options.

User avatar
jackrabbit
Joomla! Ace
Joomla! Ace
Posts: 1473
Joined: Thu May 21, 2009 3:12 am
Location: Florida
Contact:

Re: Howto dynamically switch default template for mobile dev

Post by jackrabbit » Fri May 04, 2012 7:59 pm

I tried redirection and it does return the template but it is stuck on the home page, naturally because it keeps see the same command. How can I do this correctly? Do I need to use a cookie?

include_once './templates/devices.php';
$browser = new Browser();
if( $browser->getBrowser() == Browser::BROWSER_IPHONE) {
header(location:index.php?template=mobile)
}
Reset Joomla super user password and username simply | http://cmsenergizer.com/website-energy- ... d-remotely


Locked

Return to “Templates for Joomla! 1.5”