MyBB Hacks

Full Version: Template change based on a Theme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I am testing out the MYBBGoMobile on LeeFish, and I have to say I do like it. However, I have asmall problem that one of my XThreads templates does not really show to best advantage when in the mobile view.

Is there any way that I can detect the theme that is being used and swap the template to a mobile theme if that theme is active?
may be you can use php in templates  and then in the xthread template you can write something like this:

Code:
$useragents = array ( 
'Palm' ,
'Nokia' ,
'Samsung' ,
'Motorola' ,
'iPhone' ,
'iPad' ,
'Smartphone', 
'Windows CE' ,
'Blackberry' ,
'WAP' ,
'SonyEricsson',
'PlayStation Portable', 
'LG', 
'MMP',
'OPWV',
'Symbian',
'EPOC',

); 

foreach ( $useragents as $useragents )
{
 if(strpos($_SERVER['HTTP_USER_AGENT'], $useragents) !== false)
	{
		$ismobile = 1;
	}
}
if(strpos($_SERVER['HTTP_ACCEPT'], "text/vnd.wap.wml") !== false)
         {
                $ismobile = 1;
         }

if($ismobile == 1)
       {
              //mobile compatible template
        }
else
       {
             //pc compatible templates
      } 

Hmm, but all that is already in the go mobile theme. It would be easier to just say if using theme x then...you know?
Not sure how to do that in templates in any other way.
What you are suggesting is easy if there was a template variable that returns user style but I guess there is none.
I tried {$mybb->user['style']} but does not work..
aha - you put me on the right track - thank you Smile

Code:
<if $mybb->user['style'] == $mybb->settings['gomobile_theme_id'] then>Mobile stuff<else>
Not Mobile stuff
</if>


seems to work

Wow $mybb->user['style'] worked!
But for some reason it did not worked in my forum.

Anyways glad that worked..Smile
Well, I am using the Zinga edit off github - maybe that is the difference?
Not sure it can be, may be because I am using an old version of xthread..
tsk tsk. 1.41 is really awesome with the new permissions settings and the languages. You should dl it. Is it maybe that I am using PHP in templates and you are using template conditionals?
I am still using 1.40 and it serves my purpose. I do not get lot of visitors and all so why change and modify forum functionality. I like it as it is.
As far as I know that version does not got and security issues.
I am also using PHP in templates.It might be that I used it in header template while testing, it might work in global template. I am not that bothered about it working because I dont need it..
Pages: 1 2 3
Reference URL's