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']"> vBulletin else if statement: Code:
<vb:if condition="$show['guest']"> 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. |
subscribed!
|
Thanks for this list! :)
|
Excuse me a question, to the undersigned not work conditions with $forum[forumid] is the variable that changed?
thanks PS example <vb:if condition="!in_array($forum[forumid], array(18,19))"> text text </vb:if> |
very nice, this has helped me understand all the conditionals much better.
|
subscribe too..
nice, thx u |
this is so clutch...nice
|
super, thanks & happy new yeahr ;)
|
thank you very much
|
Quote:
There's an other article here. |
Quote:
|
Hi - thanks for this post, however, can you provide conditionals for CMS sections please?
|
Quote:
You may have to preregister the var. |
Thanks
|
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"> Code:
{vb:raw $vfsms_allowed4sticky_forums} 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()); This is absolutely wrong way of doing the thing I need, pls tell me how to do it without changes in showthread.php! |
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. |
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.
|
Quote:
|
subscribed :)
|
Quote:
|
Quote:
|
Right. From my understanding you make a custom profile field and then incorporate they field number into the conditional. No?
|
you may have to also register variables depending where you want to put it.
Code:
<vb:if condition="$bbuserinfo['fieldx']"> |
I want to setup an alias for my forum, for the porn forum. So, how I can show that forum, ONLY if the people is accessing using the alias domain name?
In PHP It is easy, but i don't know how can be possible now in vB. |
I could actually kiss you , great list was waiting for some one to get a list done like this.
|
Quote:
|
Brilliant list mate :up:
Really helps, keep up the great work. Ste |
Useful for adding a advertisement or other information after the first post on every page.
Code:
<vb:if condition="!$GLOBALS['FIRSTPOSTID']"></vb:if> |
I want to use condition with the custom field. For example, I use custom field number 6 for private information, and I want the member can view it but hide it for everyone.
Is there any example? |
Excellent thank you very much :)
|
Quote:
Quote:
|
Quote:
the condition you give is for every member... it can not be used in this case. |
Quote:
Quote:
|
Hi RL714,
I think your code is right. But this is not simple likes that, because it is not for only a member or owner site. I mean the number 318713 is the dynamic number, it is exactly userid in custom field table. So if condition is: $bbuserinfo['userid'] is exactly his userid, so he can see the value. But if the other member can not see. For example: you can see your custom field number 6, but I can not see it. And vice versa, I can see my custom field number 6, but you can not see mine. |
Thanks :)
|
Thank you for the article.
Please guide me in converting this to vb4: Code:
<if condition="is_array($NewestMap)"> Code:
{$map_page} |
Thanks for your article
I want to add advertisement after the first post in some special forums so I edit the "ad_showthread_firstpost" Template and add this Code:
<vb:if condition="in_array($forum['forumid'], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if> also if I used this Code:
<vb:if condition="!in_array($forum[forumid], array(1,2,3))">Show this to forum 1, 2 and 3</vb:if> Can you advice me plz ? Best regards |
Hoping someone can help...
I'm trying to convert this template conditional (in threadbit, I'm guessing it matters)... Code:
<if condition="! $ignore[ $thread['postuserid'] ]"> Code:
<vb:if condition="!$ignore[$thread['postuserid']]"> |
Anyone know a way of getting this to work?
Code:
<vb:if condition='"{vb:raw title}" == "The Latest"'><p>ME</p></vb:if> |
Quote:
Quote:
|
All times are GMT. The time now is 08:37 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|