I’ve figured out how to get the themes to switch for mobile devices. I like SuiteR for mobile and Suite7 for desktop. The issue is switching back once the user logs out of their phone. Not sure if it’s a cache issue yet or not.
Here’s what I have so far.
This applies to SuiteCRM 7.3.1
- in include\MVC\SugarApplication.php on about line 408 replace
$theme = $GLOBALS['current_user']->getPreference('user_theme');
with
// load the user's default theme // overide if mobile
if(preg_match("/(iPhone|Mobile|android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]))
{
$theme='SuiteR';
}else{
$theme = $GLOBALS['current_user']->getPreference('user_theme');
}
This part works fine for switching the theme.
The problem I’m having is switching back.
I figure it should be in \modules\Users\Logout.php around line 52 which is
$current_user->setPreference('lastTheme',$theme);
I tried
$current_user->setPreference('lastTheme','Suite7');
$current_user->setPreference('user_theme','Suite7');
Then did a quick rebuild, clear browser cache, etc but the SuiteR theme stays when the user logs in on a desktop.
Any thoughts on how to fix the code to switch back to Suite7 or the default theme??