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: #1
Template change based on a Theme
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?


[Image: leelink.gif]
MYBB1.6 & XThreads
02-27-2011 07:24 PM
Visit this user's website Find all posts by this user Quote this message in a reply
techu Offline
Member
***
Posts: 154
Joined: Sep 2010
Post: #2
RE: Template change based on a Theme
may be you can use php in templates  and then in the xthread template you can write something like this:

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
$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
      } 


[Image: banner.png]
(This post was last modified: 02-28-2011 12:35 AM by techu.)
02-28-2011 12:25 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #3
RE: Template change based on a Theme
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?


[Image: leelink.gif]
MYBB1.6 & XThreads
02-28-2011 12:57 AM
Visit this user's website Find all posts by this user Quote this message in a reply
techu Offline
Member
***
Posts: 154
Joined: Sep 2010
Post: #4
RE: Template change based on a Theme
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..

[Image: banner.png]
02-28-2011 01:52 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #5
RE: Template change based on a Theme
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



[Image: leelink.gif]
MYBB1.6 & XThreads
02-28-2011 03:03 AM
Visit this user's website Find all posts by this user Quote this message in a reply
techu Offline
Member
***
Posts: 154
Joined: Sep 2010
Post: #6
RE: Template change based on a Theme
Wow $mybb->user['style'] worked!
But for some reason it did not worked in my forum.

Anyways glad that worked..Smile

[Image: banner.png]
(This post was last modified: 02-28-2011 03:17 AM by techu.)
02-28-2011 03:17 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #7
RE: Template change based on a Theme
Well, I am using the Zinga edit off github - maybe that is the difference?


[Image: leelink.gif]
MYBB1.6 & XThreads
02-28-2011 03:38 AM
Visit this user's website Find all posts by this user Quote this message in a reply
techu Offline
Member
***
Posts: 154
Joined: Sep 2010
Post: #8
RE: Template change based on a Theme
Not sure it can be, may be because I am using an old version of xthread..

[Image: banner.png]
(This post was last modified: 02-28-2011 03:43 AM by techu.)
02-28-2011 03:42 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*****
Posts: 1,009
Joined: Apr 2010
Post: #9
RE: Template change based on a Theme
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?


[Image: leelink.gif]
MYBB1.6 & XThreads
(This post was last modified: 02-28-2011 04:04 AM by leefish.)
02-28-2011 04:03 AM
Visit this user's website Find all posts by this user Quote this message in a reply
techu Offline
Member
***
Posts: 154
Joined: Sep 2010
Post: #10
RE: Template change based on a Theme
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..

[Image: banner.png]
02-28-2011 04:17 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: