Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 <if statements ?
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #1
<if statements ?
Hello, i'm new here and i'm finding this place very interesting. I had a small problem with groupid usage in the template files to show or hide something from certain groups. For example i would like to hide the "The newest member: xxx" line from the board stats. How can we achieve this by using the <if gid=""> in the template files? Can anyone please give the available <if clauses for various groups? thanks
10-12-2010 11:24 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*******
Posts: 1,009
Joined: Apr 2010
Post: #2
RE: <if statements ?
I know this one

Code:
<if $GLOBALS['mybb']->user['usergroup'] == 4 || $GLOBALS['mybb']->user['usergroup'] == 5 || $GLOBALS['mybb']->user['usergroup'] == 6 then> stuff for usergroup 4,5,6</if>


That would show things ONLY to the gids above.



[Image: leelink.gif]
MYBB1.6 & XThreads
10-12-2010 12:21 PM
Visit this user's website Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #3
RE: <if statements ?
Thank you very much leefish \o/

I love you man, lol.
what about <if not statement?

i want to make some stuff visible to all groups except guests. so it will better to add only guest group by using "if not" clause, which is better than adding all group ids in the "if" statement.
(This post was last modified: 10-13-2010 06:22 AM by 1master1.)
10-13-2010 06:03 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,334
Joined: Mar 2010
Post: #4
RE: <if statements ?

Code:
<if $GLOBALS['mybb']->user['usergroup'] != 1 then>
Whatever we put here, will be viewable by all usergroup, except usergroup id 1 (by default, Guests).
</if>


10-13-2010 06:40 AM
Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #5
RE: <if statements ?
worked fine with single group but can we add more than 1 group with not clause?

for exapmle: to hide it from banned members also?
<if $GLOBALS['mybb']->user['usergroup'] != 5 || $GLOBALS['mybb']->user['usergroup'] != 7 then> Text </if>

will work?
thanks to RateU and leefish
i figured it out Smile
(This post was last modified: 10-13-2010 06:54 AM by 1master1.)
10-13-2010 06:45 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,334
Joined: Mar 2010
Post: #6
RE: <if statements ?
It's better to use it like this (I think):

Code:
<if !in_array($GLOBALS['mybb']->user['usergroup'], array(1,5,7)) then>
Text
</if>


10-13-2010 06:54 AM
Find all posts by this user Quote this message in a reply
1master1 Offline
Member
***
Posts: 232
Joined: Oct 2010
Post: #7
RE: <if statements ?
worked like charm, rateu

i thought in different way <if $GLOBALS['mybb']->user['usergroup'] != 5 && $GLOBALS['mybb']->user['usergroup'] != 7 then> Text </if>

using && did the work. but your code is very simple to add any number of gids easily in array. i will make use of your code. initially leefish helped with her code
<if $GLOBALS['mybb']->user['usergroup'] == 4 || $GLOBALS['mybb']->user['usergroup'] == 5 || $GLOBALS['mybb']->user['usergroup'] == 6 then> stuff for usergroup 4,5,6</if>
which will be long if we want to use more codes. but using your array code, the length is decreased alot and simple. Smile
10-13-2010 06:59 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: