timtamboy63
Active Member
Hi Guys,
Thought i'd write a tutorial on using vBulletin conditionals, i got some spare time
What is a conditional?
Basically, its an <if> tag that checks if something is true or not.
Whatever the conditional is wrapper around is only executed/seen if the condition is met, hence the name conditional
Some Common Conditionals:
First of all Note that these conditionals havent been found by me, etc. I just googled for em :P
Anyway hers a few that i find useful
Anything wrapped in this conditional would only display to members of usergroups X,Y or Z. OBviously u can add more to the array.
Lets say you've got your ad on your header but you only want to display it on your index page. This is what this conditional does. To find out the name of the page, you have to look at the php file itself and look for
This would only show the content to one user, in this case user 667
What this does, is display the content in only a certain forum, with X,Y,Z being replace with the forum id
What this does is check the birthday of the user. Obviously replace 1980-01-01 with the birthday you want. Very Useful in adult sections.
This checks if the user is a moderator of the current forum. Replace X with the forumid
This checks if the user is the thread starter or not. Still havent found ause for this one :P
This is used to place something directly under the first post. Especially useful for ads, etc
Else and Not
Okay now for something a little more complex. With all these conditionals you can use an <else> tag to execute different information if the condition isn't met.
So for example:
This would Display Too Younf if the user didnt meet the required age
There is also the ! character. If you put that infront of the =, the conditional will check if the condition is not met.
So for example
Would display information to everyone BUT userid 667.
Some Common Screwups
I know i definately did this one a lot :P
Basically, Template Conditionals will only work in templates. Full Stop
I tried using em in bbcodes, was wondering why they didnt work :P
But yeah, now you know.
Finally got this finished, enjoy
-timtamboy63
Oh and let me know if u need any help
Thought i'd write a tutorial on using vBulletin conditionals, i got some spare time
What is a conditional?
Basically, its an <if> tag that checks if something is true or not.
Whatever the conditional is wrapper around is only executed/seen if the condition is met, hence the name conditional
Some Common Conditionals:
First of all Note that these conditionals havent been found by me, etc. I just googled for em :P
Anyway hers a few that i find useful
Code:
<if condition="is_member_of($vbulletin->userinfo, X, Y, Z)"></if>
Code:
<if condition="THIS_SCRIPT == 'index'">
Code:
define('THIS_SCRIPT', 'index');
Code:
<if condition="$bbuserinfo['userid'] == 667">
Code:
<if condition="in_array($forumid, array(X,Y,Z))">
Code:
<if condition="$bbuserinfo['birthday_search'] > '1980-01-01'">
Code:
<if condition="can_moderate($forum['X'])">
Code:
<if condition="$threadinfo['postuserid'] == $bbuserinfo['userid']">
Code:
<if condition="!$GLOBALS['FIRSTPOSTID']">
Else and Not
Okay now for something a little more complex. With all these conditionals you can use an <else> tag to execute different information if the condition isn't met.
So for example:
Code:
<if condition="$bbuserinfo['birthday_search'] > '1980-01-01'">
<!---Adult section stuff here-->
<else>
Too Young
</if>
This would Display Too Younf if the user didnt meet the required age
There is also the ! character. If you put that infront of the =, the conditional will check if the condition is not met.
So for example
Code:
<if condition="$bbuserinfo['userid'] != 667">
Some Common Screwups
I know i definately did this one a lot :P
Basically, Template Conditionals will only work in templates. Full Stop
I tried using em in bbcodes, was wondering why they didnt work :P
But yeah, now you know.
Finally got this finished, enjoy
-timtamboy63
Oh and let me know if u need any help