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
Sorry to resurrect an old thread, but I have been testing mobile on my board and I really like it. However, I have some heavily modified XThreads templates and they dont really translate too well to the mobile format. I have managed to use the conditional code below inside each template (with some success)  but it seems a long way round.

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


I have tried putting this similar code in the Template Prefix box in Edit Forum

Code:
<if $mybb->user['style'] == $mybb->settings['gomobile_theme_id'] then>mobile_,<else>
prefix_,
</if>


But it isn't working - i.e. the layout does not swap over. I DO have forum themes forced in these areas, so that may be connected. My plan of course was to make one template set for mobile viewing and that would be it. Can anyone suggest a way to do this?

Firstly, you may need to force GoMobile to run before XThreads, because, by default, it's possible that XThreads executes its code first, then GoMobile jumps in and changes the theme.
Edit the priority of the global_start hook in GoMobile or XThreads, for example, you may open gomobile.php, find:

PHP Code:
$plugins->add_hook("global_start", "gomobile_forcetheme");

and replace with

PHP Code:
$plugins->add_hook("global_start", "gomobile_forcetheme", 9);

which forces GoMobile to load before XThreads.

As for forced themes, that's a bit difficult.  I haven't tried, but you may be able to get somewhere by fiddling around with $forum['overridestyle'] and $forum['style'] and checking for those.

Yes, I know it is a long time since I started this thread, but I have not totally given up on the idea of a mobile setup.

I have tried various combinations to get the $forum['overrridestyle'} to return a result, but no luck so far. I wondered if it was because that data is in the forums cache, and if so, how would I access that data from the cache in a template conditional? This is the code I tried, to test it out.

Code:
<if $forums['overridestyle'] =0 then>
o
<else>
x
</if>


I have two forums - one with an override, one without. It appears to make no difference if I set the check to 0 (no override) or 1 (override) both forums are returning the same - either x or o.

Do you put it inside a template?
Yes, I had it inside one of my XThreads templates - in the Global templates. The XXX_forumdisplay_threadlist.
Try using $foruminfo. Something like this:

Code:
<if $foruminfo['overridestyle'] then>
Override
<else>
Not override
</if>

Yay - that worked. Now I have to figure out how to STOP it overriding and use the "standard" template set
Pages: 1 2 3
Reference URL's