Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Template change based on a Theme
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #21
RE: Template change based on a Theme
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?



[Image: leelink.gif]
MYBB1.6 & XThreads
07-03-2011 11:39 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #22
RE: Template change based on a Theme
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.


My Blog
07-04-2011 10:53 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #23
RE: Template change based on a Theme
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.



[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 04-29-2012 03:54 AM by leefish.)
04-29-2012 03:38 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #24
RE: Template change based on a Theme
Do you put it inside a template?

04-29-2012 05:13 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #25
RE: Template change based on a Theme
Yes, I had it inside one of my XThreads templates - in the Global templates. The XXX_forumdisplay_threadlist.


[Image: leelink.gif]
MYBB1.6 & XThreads
04-29-2012 07:09 AM
Visit this user's website Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,350
Joined: Mar 2010
Post: #26
RE: Template change based on a Theme
Try using $foruminfo. Something like this:

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


04-29-2012 07:17 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #27
RE: Template change based on a Theme
Yay - that worked. Now I have to figure out how to STOP it overriding and use the "standard" template set


[Image: leelink.gif]
MYBB1.6 & XThreads
04-29-2012 08:03 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: