how to change a template othe fly?

lexx006
13 years, 9 months ago
hello, everybody!
I have J!M on my site, it works good but there is one thing that...
while looking at an article page the page looks no good and I'd like to have a possibility to change articles templates on the fly.
if I'm from PC I use a normal Joomla article template and if I'm from a mobile device I'd like to use a mobile version of my article template ...
could you tell me how get to know that I came from a mobile device?
thanks for advance...
lexx006
13 years, 9 months ago
I got it:

$app = & JFactory::getApplication();
$template = $app->getTemplate();
//var_dump($template);
if($template == 'mobile_pda' ) $tpl='your_mobile_template';
dryabov
13 years, 9 months ago
if(defined('_MJ'))
{
//mobile device detected
}
lexx006
13 years, 9 months ago
ok, thanks...))
jacob001
12 years, 10 months ago
Hello,

I wasn't too worried about caching, I just needed a solution
But you're solution looks better if it achieves the same AND caches.

Not sure how your code decides to use ajaxChunk - how do I send it the parameter?

[!ajaxSwitch?
&ajaxChunk=`galleryHighslide`
&defaultChunk=`galleryStandardPage`
&cache=`1`
]]

Thanks & Regards,
Jacob
eSparkInfo
sumonht1990
12 years, 6 months ago
lexx006 wrote:
I got it:

$app = & JFactory::getApplication();
$template = $app->getTemplate();
//var_dump($template);
if($template == 'mobile_pda' ) $tpl='your_mobile_template';

Thank you. You have answered the right. I also faced the same problem.
katiewilliams
5 years, 3 months ago
Try
$app =& JFactory::getApplication();
$app->setTemplate("template2");

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.