try another color scheme:


Go Back   TECH6.0 > Web Design/Development and SEO > Internet Forum Softwares > vBulletin


vBulletin Template Conditionals List

This is a discussion on vBulletin Template Conditionals List within the vBulletin section, part of the Internet Forum Softwares category; I have listed some really useful conditionals that are widely used throughout vB . Will keep adding more. If Viewer ...

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 18-05-2008, 11:07 AM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Icon6 vBulletin Template Conditionals List

I have listed some really useful conditionals that are widely used throughout vB. Will keep adding more.

If Viewer is a Member
--------------------------------------------------
If you want to show a link only to registered members you would use this conditional.

HTML Code:
<if condition="$show['member']"></if> 
If Viewer is in the Following Usergroups Array. Enter the Usergroup Number(s) Seperated by a Comma
--------------------------------------------------
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 or Is Not XXX
--------------------------------------------------
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

PHP Code:
define('THIS_SCRIPT''showthread'); 
and the showthread part is what you would use.

HTML Code:
<if condition="THIS_SCRIPT == 'index'"></if> 
and here you can show information on every page but the index page by using this conditional

HTML Code:
<if condition="THIS_SCRIPT != 'index'"></if> 
For checking multiple scripts:

HTML Code:
<if condition="THIS_SCRIPT != 'arcade' AND THIS_SCRIPT != 'adv_index'"></if> 
OR we can use this way as well

HTML Code:
<if condition="!in_array(THIS_SCRIPT, array('arcade', 'adv_index'))"></if> 
If this user equals or does not equal xxx
--------------------------------------------------
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> 
and it works the opposite way as well if you do not want information to show for 667 but you want it to show for everyone else you would use

HTML Code:
<if condition="$bbuserinfo['userid'] != 667"></if> 
OR we can also use this way

HTML Code:
<if condition="$vbulletin->userinfo['userid'] == 667"> 
Display Information To Guests Only
--------------------------------------------------
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> 
Display Information On a Per Forum Basis
--------------------------------------------------
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> 
OR this

HTML Code:
<if condition="$foruminfo['forumid'] == X"></if> 
OR this

HTML Code:
<if condition="$forumid == X"></if> 
and on the other hand you can use the ! to do the opposite and display the information in every forum but the id you list

HTML Code:
<if condition="$forum['forumid'] != X"></if> 
or if you have multiple forums you wish to include something with you can use an array such as this

HTML Code:
<if condition="in_array($forum['forumid'], array(1,2,3,6))"></if> 
OR this

HTML Code:
<if condition="in_array($forumid, array(1,2,3,6))"> 
If Usergroup Is or Is Not X
--------------------------------------------------
If the user is a member of the x usergroup then show the code

HTML Code:
<if condition="$post['usergroupid'] == 6"></if> 
and then you can use the ! to tell it to not show it to the x usergroup but show it to everyone else.

HTML Code:
<if condition="$post['usergroupid'] != 6"></if> 
If Users Birthday is Less Than or Greater Than XXXX-XX-XX Do Something
--------------------------------------------------
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> 
and this one will show you "Too Young" if the user was born before 01-01-1980

HTML Code:
<if condition="$bbuserinfo['birthday_search'] < '1980-01-01'">Too Young</if> 
If Thread is or is not in X Forum Execute Code
--------------------------------------------------
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> 
If you want to show the piece of code on every new reply on every thread but 1 forum you can use this which says if thread is in forum x do not show the code but show it for all the other threads out side of forum x.

HTML Code:
<if condition="$thread['forumid'] != X"></if> 
and of course you can define multiple forum ids with the array

HTML Code:
<if conditional="in_array($thread['forumid'], array(1,2,3,6))"></if> 
Is user moderator of any forum?
--------------------------------------------------
If the user is a moderator execute code.

HTML Code:
<if condition="can_moderate()"></if> 
Is user moderator of current forum?
--------------------------------------------------
If the user is a moderator of the current forum execute code

HTML Code:
<if condition="can_moderate($forum['forumid'])"></if> 
Is user moderator of x Forum?
--------------------------------------------------
If the user is a moderator of x forum execute code.

HTML Code:
<if condition="can_moderate($forum['x'])"></if> 
Note: can_moderate() may add queries to your page.

Is user the thread starter?
--------------------------------------------------
Is the user the thread creator? If so execute code.

HTML Code:
<if condition="$threadinfo['postuserid'] == $bbuserinfo['userid']"></if> 
Is user the thread starter?
--------------------------------------------------
If the thread is closed execute code.

HTML Code:
<if condition="!$show['closethread']"></if> 
Place Information After First Post
--------------------------------------------------
Useful for adding a advertisement or other information after the first post on every page.

HTML Code:
<if condition="!$GLOBALS['FIRSTPOSTID']"></if> 
Place Information After x Post On Every Page
--------------------------------------------------
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> 
Using If Else in Templates
--------------------------------------------------
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> 
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #2  
Old 19-05-2008, 02:46 AM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

If unread PM
--------------------------------------------------
You can use this conditional within your templates to display something if a user has an unread PM.

HTML Code:
<if condition="$bbuserinfo['pmunread']"></if> 
If unread Notification
--------------------------------------------------
You can use this conditional to display something if a user has any unread Notification (for vB 3.7 onwards).

HTML Code:
<if condition="$show['notifications']"></if> 
If registration enabled
--------------------------------------------------
You can use this conditional to display something if registration is enabled on the board.

HTML Code:
<if condition="$show['registerbutton']"></if> 
If memberlist is viewable
--------------------------------------------------
You can use this conditional to display something if memberlist is enabled/viewable on the board.

HTML Code:
<if condition="$vboptions['enablememberlist']"></if> 
If notice is viewable
--------------------------------------------------
You can use this conditional to display something if displaying of notices conditions are met (for vB 3.7 onwards).

HTML Code:
<if condition="$show['notices']"></if> 
If Style Choosing enabled/viewable
--------------------------------------------------
You can use this conditional to display something if Style choosing dropdown is enabled/viewable in footer

HTML Code:
<if condition="$show['quickchooser']"></if> 
If Language choosing enabled
--------------------------------------------------
You can use this conditional to display something if language choosing is enabled.

HTML Code:
<if condition="$show['languagechooser']"></if> 
If Contact Us link enabled
--------------------------------------------------
You can use this conditional to display something if "Contact Us" is enabled.

HTML Code:
<if condition="$show['contactus']"></if> 
If AdminCP link enabled (or is administrator)
--------------------------------------------------
You can use this conditional to display something if "AdminCP" is enabled (or is administrator)

HTML Code:
<if condition="$show['admincplink']"></if> 
If ModCP link enabled (or is Super Moderator)
--------------------------------------------------
You can use this conditional to display something if "ModCP" is enabled (or is Super Moderator)

HTML Code:
<if condition="$show['modcplink']"></if> 
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #3  
Old 20-05-2008, 03:21 AM
iBlake's Avatar

Techie
 
Name: Blake
Join Date: May 2008
Location: United States
Phone: Not in the list
Posts: 91
iBlake is on a distinguished road
Send a message via MSN to iBlake
Default

Thanks For THis List

*Speaks to everyone* Please thank Admin for these
__________________
My iPhone is better than yours...........

I Am Back!
Reply With Quote
  #4  
Old 21-05-2008, 06:41 AM
No Avatar

Tech Addict
 
Join Date: Feb 2008
Location: India
Phone: Nokia 1110i
Posts: 164
foodland has a spectacular aura aboutfoodland has a spectacular aura about
Send a message via Yahoo to foodland
Default

thanks for the information.... great...
Reply With Quote
  #5  
Old 19-08-2008, 08:12 AM
No Avatar

Learner
 
Name: Craig
Join Date: Aug 2008
Location: United States
Phone: LG VX9800
Posts: 5
daggerzz is on a distinguished road
Default

This is a great list but im trying to use this code and it doesnt seem to work
HTML Code:
<if condition="$threadinfo['postuserid'] == $bbuserinfo['userid']"></if> 

the other codes ive tried seem to work fine

any ideas?
Reply With Quote
  #6  
Old 19-08-2008, 06:33 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

hmm.. Thread Starter conditional.

ok, try this.

HTML Code:
<if condition="$thread['postuserid'] == $bbuserinfo['userid'] && $thread['firstpostid'] = $bbuserinfo['userid']"> 
Should work if used in threadbit...

I tried searching for this, and found few more. Do try them as well.

HTML Code:
<if condition="$thread['postuserid'] == $userinfo['userid']"> 
HTML Code:
<if condition="$thread['postuserid'] == $post['userid']"> 
HTML Code:
<if condition="$thread['postuserid'] == $bbuserinfo['userid']"> 
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #7  
Old 19-08-2008, 07:13 PM
No Avatar

Learner
 
Name: Craig
Join Date: Aug 2008
Location: United States
Phone: LG VX9800
Posts: 5
daggerzz is on a distinguished road
Default

it seems like $thread['postuserid'] doesnt exist
but $thread['firstpostid'] does exist as I can echo it to my screen is there a way to get the first pos tuserid from this thread number?
Reply With Quote
  #8  
Old 19-08-2008, 07:30 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

Did you tried the first conditional ??

It works perfect for me.

HTML Code:
<if condition="$thread['postuserid'] == $bbuserinfo['userid'] && $thread['firstpostid'] = $bbuserinfo['userid']">
hiiiiiiiiiiiiiiiiiii
</if> 
I had put the above code in postbit template and can see "hiiiiiiiiiiiiiiiiiiiii" printed only in threads that I had started.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #9  
Old 19-08-2008, 09:55 PM
No Avatar

Techie
 
Join Date: Aug 2008
Location: United States
Posts: 54
MisawaPlayer is on a distinguished road
Send a message via Yahoo to MisawaPlayer
Default An Expanded Explanation

I'm working with Daggerzz on this "project" and feel that we might need to provide an expanded explanation of what we want to do.

We are trying to put a button next to the "Quote" button on each post. This button should be visible to only the original thread poster. The thread poster can normally be found in $threadinf[postuserid], but appears to have no value assigned in the postbit_legacy style. I believe this is the correct location to be making this button appear, but if I am wrong, please tell me.

So, values of $post, $userinfo, and $bbuserinfo are all visible to me. I have output the values to my screen as a means of debugging and ensuring the values exist. $threadinfo['postuserid'] does not actually display anything though. It appears to have not been set.

So, is there a way to create the conditional, basically asking "if current user = original thread poster" do something?

Thank you for your help.
Reply With Quote
  #10  
Old 19-08-2008, 10:17 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

i have understood what you want. And I believe you know the difference between postbit and postbit_legacy.

I have just now performed the same task on my test site. I added another button besides Edit, Quote etc. in postbit_legacy template and wrapped it with the conditional that made it appear ONLY to the thread starter. This is only what you want, right ??
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #11  
Old 19-08-2008, 10:36 PM
No Avatar

Techie
 
Join Date: Aug 2008
Location: United States
Posts: 54
MisawaPlayer is on a distinguished road
Send a message via Yahoo to MisawaPlayer
Default I am not as smart as you may think - lol

i have understood what you want. And I believe you know the difference between postbit and postbit_legacy.

I have just now performed the same task on my test site. I added another button besides Edit, Quote etc. in postbit_legacy template and wrapped it with the conditional that made it appear ONLY to the thread starter. This is only what you want, right ??
As Said by webwizzy View Post
Actually, I am not too sure of the difference between postbit and postbit_legacy, so any explanation there would be nice.

Yes, this is what I want, but when I put in the conditional
<if condition="$thread['postuserid'] == $bbuserinfo['userid'"]>, it placed the button for every user. I tested the following:

Admin's userid = 1 created the thread's first post.

<if condition="$bbuserinfo['userid'] == 1"> and as Admin the button showed.

<if condition="$thread['postuserid'] == 1"> and the button did not show.

I also attempted to simply output these two values to the screen. The first gave me "1", while the second displayed nothing.

If this worked, in postbit_legacy for you, please, what am I missing?
Reply With Quote
  #12  
Old 19-08-2008, 10:42 PM
No Avatar

Techie
 
Join Date: Aug 2008
Location: United States
Posts: 54
MisawaPlayer is on a distinguished road
Send a message via Yahoo to MisawaPlayer
Default Sorry, a mistake

I made a mistake in the previous post -

<if condition="$thread['postuserid'] == $bbuserinfo['userid'"]> displayed no button.

What I did say, happened to me at 3 in the morning, but there was a complete different mistake that I realized right away.
Reply With Quote
  #13  
Old 19-08-2008, 10:47 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

postbit and postbit_legacy are nothing but 2 separate templates that have their own style of display. They basically differ only in placement of the user's avatar and other info. As in this site you can see, we are using the postbit template where the poster details lie above the post content UNLIKE in postbit_legacy template where the poster details are displayed vertically in a column parallel to the post content. For more details, read this.

I have just PM'd you a link to my test board so that you can see what I have done there.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #14  
Old 19-08-2008, 10:48 PM
No Avatar

Techie
 
Join Date: Aug 2008
Location: United States
Posts: 54
MisawaPlayer is on a distinguished road
Send a message via Yahoo to MisawaPlayer
Default Thank you

Thank you for the explanation, as well as the link. I will take a look at it in a few.
Reply With Quote
  #15  
Old 19-08-2008, 10:52 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

I forgot to mention, login with the test a/c there and post a thread. You would notice a second Edit button with the alt text 2nd Edit button (this would appear only on YOUR created threads)

Also notice the postbit_legacy template there. See the difference now.

If that is what you are looking for, then you can do it this way:-

Find this in postbit/postbit_legacy (whichever you use):-

HTML Code:
<!-- controls --> 
Add below:-

HTML Code:
<if condition="$thread['postuserid'] == $bbuserinfo['userid'] && $thread['firstpostid'] = $bbuserinfo['userid']">            
<a href="http://........"><img src="$stylevar[imgdir_button]/edit2.gif" alt="Thread Starter button" border="0" /></a></if> 
Hope this solves your problem.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #16  
Old 20-08-2008, 12:09 AM
No Avatar

Techie
 
Join Date: Aug 2008
Location: United States
Posts: 54
MisawaPlayer is on a distinguished road
Send a message via Yahoo to MisawaPlayer
Default Thank you...

I think you gave us the information we needed in the first or second reply, but we missed one important thing. In your original post to this thread, the following is listed:

Is user the thread starter?
--------------------------------------------------
Is the user the thread creator? If so execute code.

<if condition="$threadinfo['postuserid'] == $bbuserinfo['userid']"></if>



Your response when we said it didn't work, was this:

<if condition="$thread['postuserid'] == $bbuserinfo['userid']"></if>

I at least, missed the change from $threadinfo to $thread.

Also, the second half of this

&& $thread['firstpostid'] = $bbuserinfo['userid'] was absolutely necessary. Can you explain why the "and" is necessary?

Anyway, it is working for me now and I thank you. Sorry for the hassle involved in my not catching everything you told me.
Reply With Quote
  #17  
Old 20-08-2008, 08:25 AM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

See I think the reason why ONLY the conditional before the && not working is missing of $thread['firstpostid']. There's no way the conditional is finding out if that is the first post in the specific thread or not.

anyways.. I am really happy I could help you out

You also contributed to the 1000th post for this site. So thank you sir !
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #18  
Old 20-08-2008, 02:12 PM
No Avatar

Techie
 
Join Date: Aug 2008
Posts: 52
UaECasher is on a distinguished road
Default

great list ^_^ thanks
Reply With Quote
  #19  
Old 20-04-2009, 11:07 AM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

Browser compatibility has become quite an issue now due to a variety of them being used by different people. vB handles all browsers check with its is_browser function:-

If browser is Internet Explorer:-

HTML Code:
<if condition="is_browser('ie')"></if> 
Similarly, replace ie with opera, safari, mozilla etc for handling other browsers.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #20  
Old 15-10-2009, 05:36 AM
LeVampirE's Avatar

Learner
 
Join Date: Oct 2009
Posts: 4
LeVampirE is on a distinguished road
Default

thanx this really amazing man, :d i love you for this
Reply With Quote
Reply

Bookmarks

Tags
template conditionals, vbulletin


Thread Tools
Display Modes




All times are GMT +5.5. The time now is 01:38 PM.

Contact Us - Tech6.com - Link to Us - Advertise - Submit Site - Privacy Statement - TOS - Top