Welcome, Guest
Username Password: Remember me

how to change a template othe fly?
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: how to change a template othe fly?

how to change a template othe fly? 13 years, 9 months ago #3485

  • lexx006
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
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...
Last Edit: 13 years, 9 months ago by lexx006.

Re: how to change template othe fly? 13 years, 9 months ago #3486

  • lexx006
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
I got it:

$app = & JFactory::getApplication();
$template = $app->getTemplate();
//var_dump($template);
if($template == 'mobile_pda' ) $tpl='your_mobile_template';
The following user(s) said Thank You: sumonht1990

Re: how to change template othe fly? 13 years, 9 months ago #3487

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
if(defined('_MJ'))
{
//mobile device detected
}

Re: how to change template othe fly? 13 years, 9 months ago #3496

  • lexx006
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
ok, thanks...))

Re: how to change a template othe fly? 12 years, 10 months ago #6956

  • jacob001
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0
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
The following user(s) said Thank You: sumonht1990

Re: how to change template othe fly? 12 years, 6 months ago #9392

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.

Re: how to change a template othe fly? 5 years, 2 months ago #21512

Try
$app =& JFactory::getApplication();
$app->setTemplate("template2");
  • Page:
  • 1
Time to create page: 0.13 seconds

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.