The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
vBulletin Template Conditionals
Just a little something I got permission from Brandon here to post here on vB.org. I figured that it would come in handy to quite a few people especially those of us who code so much. I've had to refer back to this several times myself. I'll be adding more periodically but if you have any of your own, please feel free to add them to this thread. Thank you! Display Information To Members Only -------------------------- If you want to show a link only to registered members you would use this conditional. HTML Code:
<if condition="$show['member']"></if> -------------------------- The following conditional will display information only to guests and no one else. This is helpful in displaying a welcome message that you only wish for guests to see. HTML Code:
<if condition="$show['guest']"></if> -------------------------- If you want to show an advertisement to viewers that are unregistered, registered members and awaiting email confirmation you would use the usergroup ids 1,2,3 within the array. HTML Code:
<if condition="is_member_of($vbulletin->userinfo, 1, 2, 3)"></if> -------------------------- If this script is index (as used in the example below) then it will show the code within the conditional. You can use it to show a piece of code only on Forumhome if you have to put it in a template that is global such as the header. To find out what the script is per page open up the php file that loads the page like for instance showthread.php and look for. HTML Code:
define('THIS_SCRIPT', 'showthread'); HTML Code:
<if condition="THIS_SCRIPT == 'index'"></if> HTML Code:
<if condition="THIS_SCRIPT != 'index'"></if> -------------------------- What this conditional will do is only show certain information if the person viewing the page has the same userid as defined within the conditional. So if you put userid 667 inside the conditional below and put a link inside the conditional tags only the user that has the userid 667 will see that link. HTML Code:
<if condition="$bbuserinfo['userid'] == 667"></if> HTML Code:
<if condition="$bbuserinfo['userid'] != 667"></if> -------------------------- This conditional allows you to display information on a per forum basis. This can be helpful if you wish to display different advertisements depending on what forum that the user is in. You would simply replace X with the forum id that you wish the information to appear in. HTML Code:
<if condition="$forum[forumid] == X"></if> HTML Code:
<if condition="$forum[forumid] != X"></if> HTML Code:
<if condition="in_array($forum['forumid'], array(1,2,3,6))"></if> -------------------------- If the user is a member of the x usergroup then show the code. HTML Code:
<if condition="$post['usergroupid'] == 6"></if> HTML Code:
<if condition="$post['usergroupid'] != 6"></if> -------------------------- Just to show the power of vBulletin here is a cool conditional that will show information based on the birthday of the user. The one below will show "Too Young" if they were born after 01-01-1980. HTML Code:
<if condition="$bbuserinfo['birthday_search'] > '1980-01-01'">Too Young</if> HTML Code:
<if condition="$bbuserinfo['birthday_search'] < '1980-01-01'">Too Young</if> -------------------------- For instance if you want a piece of code to appear within thread in a particular forum you can do so with this conditional. HTML Code:
<if condition="$thread['forumid'] == X"></if> HTML Code:
<if condition="$thread['forumid'] != X"></if> HTML Code:
<if condition="in_array($thread['forumid'], array(1,2,3,6))"></if> -------------------------- If the user is a moderator execute code. HTML Code:
<if condition="can_moderate()"></if> -------------------------- If the user is a moderator of the current forum execute code. HTML Code:
<if condition="can_moderate($forum['forumid'])"></if> -------------------------- If the user is a moderator of x forum execute code. HTML Code:
<if condition="can_moderate($forum['x'])"></if> -------------------------- Is the user the thread creator? If so execute code. HTML Code:
<if condition="$threadinfo['postuserid'] == $bbuserinfo['userid']"></if> -------------------------- If the thread is closed execute code. HTML Code:
<if condition="!$show['closethread']"></if> -------------------------- Useful for adding a advertisement or other information after the first post on every page. HTML Code:
<if condition="!$GLOBALS['FIRSTPOSTID']"></if> -------------------------- This will add your code directly after the post number you define on each page. If you put 2 in place of x the code will appear on every page after the second post. HTML Code:
<if condition="$post['postcount'] % $vboptions['maxposts'] == x"></if> -------------------------- You can also use If Else conditionals within your templates. The below shows you how to correctly do this. HTML Code:
<if condition="$show['guest']"> Show Guest This Message <else /> Show Everyone but guests this message </if> |
#72
|
||||
|
||||
Thanks for the fix, but it doesnt work I changed the code to make testing have less variables
Quote:
|
#73
|
||||
|
||||
Try this: (sometimes && doesn't doesn't play well in templates)
HTML Code:
<if condition="$show['newthreadlink'] AND $forum['forumid'] == 8"> <a href="complaints-suggestions.php" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a> <else /> <a href="newthread.php?$session[sessionurl]do=newthread&f=$foruminfo[forumid]" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a> </if> |
#74
|
||||
|
||||
Quote:
HTML Code:
<if condition="$show['newthreadlink'] AND $thread['forumid'] == 8"> <a href="complaints-suggestions.php" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a> <else /> <a href="newthread.php?$session[sessionurl]do=newthread&f=$foruminfo[forumid]" rel="nofollow"><img src="$stylevar[imgdir_button]/newthread.gif" alt="$vbphrase[post_new_thread]" border="0" /></a> </if> |
#75
|
||||
|
||||
Quote:
@TheLastSuperman, this is for VB3. |
#76
|
||||
|
||||
If you search the template you are putting the custom code in, look at what variable names are already being used.
In showthread $forum is never used... Nor is $thread, the actual one used is $threadinfo. In forumdisplay it's $foruminfo.... So for the forumdisplay template this would be the code: PHP Code:
|
#77
|
||||
|
||||
OMG THAT WORKED!
Thank you Thank you! THANK YOU! |
Благодарность от: | ||
BirdOPrey5 |
#78
|
||||
|
||||
Late reply, but had the same question myself. (At least I think it's the same question.)
Looked in the db, read some docs, and got it right on the first try. Code:
<if condition="$thread[postuserid] == 15"> CODE </if> Code added to the template could show a message to members/guests (unless further limited by more conditionals), in posts created by this specific thread starter. For example, to add a unique secondary signature by an admin in new threads. You can hard code the message, or add a new phrase variable. ### |
#79
|
|||
|
|||
thanks.
|
#80
|
|||
|
|||
Quote:
Code:
<if condition="in_array($forum[forumid], array(2, 3, 4, 5, 6 ))"> Code:
<if condition="!in_array($forum[forumid], array(2, 3, 4, 5, 6 ))"> |
#81
|
||||
|
||||
Thanks. Updated original post. :up:
|
Thread Tools | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|