Announcement

  •  » Themes
  •  » I have SOLUTION for Mobile Theme for Tablets (mobile)

#1 2016-09-14 22:18:24

newseed
Member
2015-10-22
10

I have SOLUTION for Mobile Theme for Tablets (mobile)

Right off the top, I am not a programmer but I have a solution to the plugin for those that are using a desktop theme along with Smart Pocket mobile theme. 

People were complaining that the mobile plugin does not work out of the box. When you have the first two check boxes checked it still does not display the Smart Pocket mobile theme. However, people found that by checking the last check box (for desktop) it shows the mobile version but then the downside is that the mobile theme also appears for desktop browsers. 

After looking around I thought I would try to reverse the session value from 1 to 0 in the functions.inc.php file and that cause the mobile to display by default.  I then edited the value 'true' and 'false' to be the opposite thus 'false' and 'true' respectively.  And that solved the problem.

It seems that the developer either inadvertently had his/her logic backwards or it was just a plain oversight.

First off, via the admin, make sure the configuration for Mobile Theme for Tablets is set correctly. There are 3 check boxes. The first two should be checked leaving the last one (Desktop) unchecked.

Now it's time to edit a file:

Open the functions.inc.php file located in that plugin's folder:
/plugins/Mobile_Theme_for_Tablets/include/functions.inc.php

You will see the following block of code:



/**
* activate the mobile theme
*/
function mtt_activate_mobile_theme() {
    global $conf;

    $conf_mtt = unserialize($conf['mobile_theme_for_tablets']);
   
    if (isset($conf_mtt['devices'][pwg_get_session_var('device')]) && $conf_mtt['devices'][pwg_get_session_var('device')] == '1') {
            pwg_set_session_var('mobile_theme', true);
        } else {
            pwg_set_session_var('mobile_theme', false);
        }
}

You need to edit 3 places:

Edit line 10 session var value from '1' to be '0'

Edit line 11 session var value 'true' to be 'false'

Edit line 13 session var value 'false' to be 'true'


It should look like the follow:



/**
* activate the mobile theme
*/
function mtt_activate_mobile_theme() {
    global $conf;

    $conf_mtt = unserialize($conf['mobile_theme_for_tablets']);
   
    if (isset($conf_mtt['devices'][pwg_get_session_var('device')]) && $conf_mtt['devices'][pwg_get_session_var('device')] == '0') {
            pwg_set_session_var('mobile_theme', false);
        } else {
            pwg_set_session_var('mobile_theme', true);
        }
}


The first check box does not seem to be affected whether it's checked or not but that's because the value is set to '0' which makes the mobile theme default anyway. Checking the second and/or third check boxes works as expected. When checked it shows the mobile version. When unchecked it shows the desktop version.

Hope this helps.

Last edited by newseed (2016-09-14 22:59:13)

Offline

 
  •  » Themes
  •  » I have SOLUTION for Mobile Theme for Tablets (mobile)

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact