The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
vB4 Template Conditionals List
I put this together because it seems lots of people are having problems with the new syntax for conditionals. First off remember you can not use {vb:raw var} in template conditionals. Show only members: Code:
<vb:if condition="$show['member']">Show this to members only</vb:if> Show only guest: Code:
<vb:if condition="$show['guest']">Show this to guest only</vb:if> Show specific user groups : Code:
<vb:if condition="is_member_of($bbuserinfo, 1,2,3)">Show this to user group 1, 2, and 3</vb:if> Show one member: Code:
<vb:if condition="$bbuserinfo['userid'] == 318713">Show this only to the member with the user id of 318713</vb:if> Show every one but one member: Code:
<vb:if condition="$bbuserinfo['userid'] != 318713">Show this to every one but the member with the user id of 318713</vb:if> Show only moderators of any forum: Code:
<vb:if condition="can_moderate()">Show this to all moderators</vb:if> Code:
<vb:if condition="can_moderate($forum['x])">Show this if moderator is moderator of the forum with the id of x</vb:if> Show Moderator of current forum: Code:
<vb:if condition="can_moderate($forum['forumid'])">Show this to the moderator of the current forum</vb:if> Show in one forum: Remember to change x Code:
<vb:if condition="$forum[forumid] == x">Show this if forum id is x</vb:if> Show is every forum but one: Remember to change x Code:
<vb:if condition="$forum[forumid] != x">Show this if forum id is not x</vb:if> Show in several forums: Code:
<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if> Show in only one file: Look for define('THIS_SCRIPT', 'calendar'); in the top of the php file you want it to show in. Code:
<vb:if condition="THIS_SCRIPT == 'calendar'">Show this only on calendar.php</vb:if> Show in every file but one: Look for define('THIS_SCRIPT', 'calendar'); in the top of the php file you do not want it to show in. Code:
<vb:if condition="THIS_SCRIPT != 'calendar'">Show this only on calendar.php</vb:if> If $customvar is set: Code:
<vb:if condition="$customvar">Show this if $customvar is set</vb:if> If $customvar equals: Code:
<vb:if condition="$customvar == blah">Show this if $customvar equals blah</vb:if> If $customvar does not equal: Code:
<vb:if condition="$customvar != blah">Show this if $customvar does not equal blah</vb:if> vBulletin else statement: Code:
<vb:if condition="$show['guest']"> Show this to only guest. <vb:else /> Show this to all registered users </vb:if> vBulletin else if statement: Code:
<vb:if condition="$show['guest']"> Show this to only guest. <vb:elseif condition="is_member_of($bbuserinfo, 5,6)" /> Show this to user group 5 and 6 which is mods and admins <vb:else /> Show this to all registered users </vb:if> This is all that I can think of right now off the top of my head. Please feel free to add any I forgot and I will add them to this list and give you credit. |
#362
|
|||
|
|||
Thanks a lot Lynne! It worked. I appreciate it!
|
#363
|
|||
|
|||
This is driving me up the f*cking wall. Can someone help me?
I've created a custom forum block template that I want to use for advertisements only. Basically, I want the advertisements to display to everyone EXCEPT for our subscribers. I've tried variations of code but either the advertisements appear to all usergroups or to none. Code:
<vb if condition="is_member_of($bbuserinfo, 1,2,3,4,5,6,7,8,15,16,17)"> <li> <div class="block smaller"> <div class="blocksubhead"> <a class="collapse" id="collapse_block_html_{vb:raw blockinfo.blockid}" href="{vb:raw relpath}#top"><img alt="" src="{vb:stylevar imgdir_button}/collapse_40b.png" id="collapseimg_html_{vb:raw blockinfo.blockid}"/></a> <span class="blocktitle">{vb:raw blockinfo.title}</span> </div> <div class="widget_content blockbody floatcontainer"> <div id="block_html_{vb:raw blockinfo.blockid}" class="blockrow"> {vb:raw content} </div> </div> </div> <div class="underblock"></div> </li> </vb:if> I can't seem to add an ELSE statement of any kind because all I get is an "Invalid Nesting" error. |
#364
|
|||
|
|||
I think the problem might be caching. Try setting "Cache Time" to 0 and see if that works.
You should be able to use <vb:else /> to have an else section (but it needs the closing slash). ETA: also, your first line is missing a colon. It should start with <vb:if condition=.... |
#365
|
|||
|
|||
What should I add after <vb:else />?
|
#366
|
|||
|
|||
Well, I was just answering where you said you couldn't get any "else" to work. But I guess you'd do something like:
Code:
<vb:if condition="is_member_of($bbuserinfo, 1, 2, 3)"> Stuff to show to groups 1, 2, 3 <vb:else /> Stuff to show everyone else </vb:if> Do you have it working at all yet? |
#367
|
|||
|
|||
I've got it how I described in the original post, except now with the colon. All groups can see the advert.
I'm trying to get it so that subscribers (11) don't see the advert, or the forum block for that matter. |
#368
|
|||
|
|||
So how did you create it exactly? Did you choose "Custom HTML/PHP" block? And how did you fill in the rest of the form?
|
#369
|
|||
|
|||
I copied the original block_html template and then made a new one named "adblock_html" with the same coding. I then added the conditionals (see above) and adjusted the settings for my Amazon advert block to use the "adblock_html" template.
|
#370
|
|||
|
|||
That sounds good. Did you set the cache time to 0?
As Scanu posted in the other thread, something like this should work and it's a little shorter: Code:
<vb:if condition="!is_member_of($bbuserinfo, 11)"> <li> <div class="block smaller"> <div class="blocksubhead"> <a class="collapse" id="collapse_block_html_{vb:raw blockinfo.blockid}" href="{vb:raw relpath}#top"><img alt="" src="{vb:stylevar imgdir_button}/collapse_40b.png" id="collapseimg_html_{vb:raw blockinfo.blockid}"/></a> <span class="blocktitle">{vb:raw blockinfo.title}</span> </div> <div class="widget_content blockbody floatcontainer"> <div id="block_html_{vb:raw blockinfo.blockid}" class="blockrow"> {vb:raw content} </div> </div> </div> <div class="underblock"></div> </li> </vb:if> |
#371
|
|||
|
|||
What the...
I swear I did that yesterday. xD Ah well, that seems to have done the trick! Thank you very much mate! Gosh, all this stuff isn't very noob friendly haha. |
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|