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. |
#12
|
||||
|
||||
thanks, I must enter the new logic. Happy New Year
|
#13
|
||||
|
||||
Hi - thanks for this post, however, can you provide conditionals for CMS sections please?
|
#14
|
||||
|
||||
Quote:
You may have to preregister the var. |
#15
|
|||
|
|||
Thanks
|
#16
|
|||
|
|||
Hello everybody! I have one problem with porting one of my products to VB4.
I have the setting for a product called vfsms_can_stick_by_sms - it's comma separated list of forum-sections where this product is turned on. In this product I have the following plugin: Code:
<plugin active="1" executionorder="5"> <title>Detecting can thread in this forum can be stick up by SMS or not.</title> <hookname>showthread_start</hookname> <phpcode> <![CDATA[ $vfsms_can_stick_by_sms_forums_ids = str_replace(' ', '', $vbulletin->options['vfsms_can_stick_by_sms']); $vfsms_allowed4sticky_forums = explode(',', $vfsms_can_stick_by_sms_forums_ids); // I've already read article from this forum abt passing variables to the template engine vB_Template::preRegister('SHOWTHREAD', array('vfsms_allowed4sticky_forums' => $vfsms_allowed4sticky_forums)); ]]> </phpcode> </plugin> Code:
{vb:raw $vfsms_allowed4sticky_forums}
{vb:raw $forumid}
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="margin:10px">
<tr>
<td align="center">
<vb:if condition="$vbulletin->userinfo['userid'] == $threadinfo['postuserid'] AND ($threadinfo['sticky_till'] != '0000-00-00 00:00:00' AND $threadinfo['sticky'] == 1)">
Your thread is sticky untill <b style="color: red;">{vb:raw threadinfo.sticky_till}</b>!<br />
For prolongation send sms with the text <b style="color: red;">#vf sticky {vb:raw threadinfo.threadid}</b> to the number <b style="color: blue;">{$vbulletin->options[vfsms_sticky_num]}</b>.
<vb:elseif condition="$vbulletin->userinfo['userid'] == $threadinfo['postuserid'] AND $threadinfo['sticky_till'] == '0000-00-00 00:00:00' AND $threadinfo['sticky'] == 0 AND in_array($forumid, $vfsms_allowed4sticky_forums)" />
You can make your topic sticky by sending SMS with text <b style="color: red;">#vf sticky {vb:raw threadinfo.threadid}</b> to the number <b style="color: blue;">{$vbulletin->options[vfsms_sticky_num]}</b>.
<vb:else />
You can not make your topic sticky.
</vb:if>
</td>
</tr>
</table>
1. variable $vfsms_allowed4sticky_forums can be accessed only as a {vb:raw vfsms_allowed4sticky_forums} and I can not put it to the condition 2. variable $forumid is not accessible anymore Please, somebody, help me! --------------- Added [DATE]1262737717[/DATE] at [TIME]1262737717[/TIME] --------------- but everything is ok if I pass variable directly from the showthread.php: Code:
1. find showthread.php:2228 print_output($templater->render()); 2. replace on This is absolutely wrong way of doing the thing I need, pls tell me how to do it without changes in showthread.php! |
#17
|
||||
|
||||
well first off this is a thread for conditionals. Thats why your not getting much help with your whole script.
Do you have a conditional specific question? If not please start a new thread and do not hijack this one. |
#18
|
|||
|
|||
How would I make it so a profile option could disable a toolbar? To be more specific I am trying to make Tweetboard and Wibiya Toolbars optional via user options.
|
#19
|
||||
|
||||
Do you have a conditional specific question? If not please start a new thread and do not hijack this one.
|
#20
|
||||
|
||||
subscribed
|
#21
|
|||
|
|||
I apologize. I was wondering for the conditional tags to use to accomplish this.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|