Welcome, Guest
Username Password: Remember me

Switching between mobile templates...
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Switching between mobile templates...

Switching between mobile templates... 12 years, 9 months ago #7501

  • jfaheygm
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Karma: 0
Hello all. I was wondering if anyone has come across this or could at least help. I have a site that already has mobile joomla and it is using the templates that came with the component. We just built a new desktop template for a section of this site. This section needs to have a different feel to it than the main site. We want to do the same with the mobile aspect as well. I was assuming I could assign my new mobile template to the new menu items but this does not work. It always defaults to the template chosen in the mobile component. Is there a way to use two different mobile templates on the same site?

Oh, Joomla 1.5.25 and most recent Mobile Joomla update.

Thanks in advance for any help.

Re: Switching between mobile templates... 12 years, 8 months ago #7774

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
By default MJ allows to have one template per device mode. If you like to use additional template for a part of site, you should write a plugin that will change template in "onMobile" event.

Re: Switching between mobile templates... 12 years, 8 months ago #7784

Please let me know if you have any updates with this matter as it is exactly the feature I have spent hours trying to manipulate for my University project

Re: Switching between mobile templates... 12 years, 5 months ago #9791

  • ctm
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
  • Karma: 0
If you are still looking for a fix for this, I had the same issue, wanted to have multiple smartphone templates because my mobi site has 3 different color themes.

This is for Joomla 2.5.4 and latest MJ

Open file: /plugins/system/mobilebot/mobilebot.php

(about line 375)
//Set template
if($template)

put these lines of code just before this:

$menuid = JSite::getMenu()->getActive()->id;
$db = JFactory::getDBO();
$query = "SELECT template_style_id FROM #__menu WHERE id = ".$menuid;
$db->setQuery($query);
$template_id = $db->loadResult();

if ($template_id != '0') {
$query = "SELECT template FROM #__template_styles WHERE id = ".$template_id;
$db->setQuery($query);
$template = $db->loadResult();
}

You can now go ahead and install new templates and assign them to menu items, this code assumes that mj_smartphone is set as the default template in MJ component settings under Smartphone
The following user(s) said Thank You: jfaheygm

Re: Switching between mobile templates... 12 years, 5 months ago #9795

  • jfaheygm
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Karma: 0
That is completely awesome that you figured this out. I do have one question though. What if I don't use ANY of the Mobile Joomla templates? I make my own mobile templates. You said it is based on using the smartphone template. Thanks again for this regardless.

Re: Switching between mobile templates... 12 years, 5 months ago #9797

  • ctm
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
  • Karma: 0
It should still work the same, surely one of those custom templates of yours will be a default template, so just select your default from the drop down under Smartphone or Iphone tab in the MJ settings and assign the rest to menu items under the template manager of Joomla. Let me know if it works for you.

Re: Switching between mobile templates... 12 years, 5 months ago #9798

  • jfaheygm
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Karma: 0
I can not get it to work. Where ever I put the code you provided it gives me an error. If you could point me more specifically where to paste it I would appreciate it. Here is the code I have in the mobilebot.php file:

//Set template
if($template)

{

if(!$is_joomla15)
{
$db = JFactory::getDBO();
$query = "SELECT params FROM #__template_styles WHERE client_id = 0 AND template = ".$db->Quote($template)." ORDER BY id LIMIT 1";
$db->setQuery($query);
$params_data = $db->loadResult();
if(empty($params_data))
$params_data = '{}';
}
if(version_compare(JVERSION,'1.7','ge'))
{
$app->setTemplate($template, $params_data);
}
elseif(version_compare(JVERSION,'1.6','ge'))
{
$app->setTemplate($template);
$template_obj = $app->getTemplate(true);
$template_obj->params->loadJSON($params_data);
}
else
{
$app->setUserState('setTemplate', $template);
$app->setTemplate($template);
}
}

Re: Switching between mobile templates... 12 years, 5 months ago #9799

  • ctm
  • OFFLINE
  • Fresh Boarder
  • Posts: 17
  • Karma: 0
What error do you get?

This is what my file looks like:

switch($MobileJoomla_Device['markup'])
{
case 'xhtml':
case 'wml':
case 'chtml':
case 'iphone':
$template = $MobileJoomla->getParam('template');
$homepage = $MobileJoomla->getParam('homepage');
$gzip = $MobileJoomla->getParam('gzip');
break;
}

$menuid = JSite::getMenu()->getActive()->id;
$db = JFactory::getDBO();
$query = "SELECT template_style_id FROM #__menu WHERE id = ".$menuid;
$db->setQuery($query);
$template_id = $db->loadResult();

if ($template_id != '0') {
$query = "SELECT template FROM #__template_styles WHERE id = ".$template_id;
$db->setQuery($query);
$template = $db->loadResult();
}

//Set template
if($template)
The following user(s) said Thank You: jfaheygm

Re: Switching between mobile templates... 12 years, 5 months ago #9800

  • jfaheygm
  • OFFLINE
  • Fresh Boarder
  • Posts: 11
  • Karma: 0
If worked this time. I did paste it in that same spot before. Not sure what happened but either way, you are awesome. I don't suppose you have done this on a 1.5 site? lol. Most of my companies sites are 2.5 and we are slowly migrating the older ones but I have one HUGE 1.5 site that is last on the list I could use this for. The code of course is completely different.
  • Page:
  • 1
Time to create page: 0.11 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.