PDA

View Full Version : Help with conditionals


jwashburn
03-14-2009, 03:33 PM
I am a code novice.

I am trying to hide the New Thread button for certain usergroups. They can reply to an existing thread but not create new threads. I can control this with permissions, but I am tying to hide the button.

I found the code in ForumDisplay
<if condition="$show['newthreadlink']"><a href="newthread.php?$session[sessionurl]do=newthread&amp;f=$foruminfo[forumid]" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a><else />&nbsp;</if></td>

I also found articles on how to use conditionals from https://vborg.vbsupport.ru/showthread.php?t=98009

<if condition="is_member_of($bbuserinfo, 6)">
If in group 6, show this...
<else />
...or else, show this.
</if>

I am trying to integrate these two. Basically I only want the new thread button to be available for Admins. (its actually the new review button, I am modifying a GARS template.)

I am ok with basic if else principles, but these are nested and I am getting confused

Lynne
03-14-2009, 03:38 PM
Your condition looks fine. Did you try it? Another way to go about it would be to create a plugin that sets $show['newthreadlink'] to false for users not in the admin usergroup.

jwashburn
03-14-2009, 03:50 PM
Sorry, I actually got it working. I didnt realize there were two buttons. I had made the bottom button dissapear the whole time.

For anyone who may read this. This is what I did

<td class="smallfont"><if condition="is_member_of($bbuserinfo, 6)">
<if condition="$show['newthreadlink']"><a href="newthread.php?$session[sessionurl]do=newthread&amp;f=$foruminfo[forumid]" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a><else />&nbsp;</if>
<else />
&nbsp
</if>
</td>