| |||||||
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 ...
![]() |
|
| | LinkBack | Thread Tools | Display Modes |
|
#1
| ||||
| ||||
|
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 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 PHP Code: HTML Code: <if condition="THIS_SCRIPT == 'index'"></if> HTML Code: <if condition="THIS_SCRIPT != 'index'"></if> HTML Code: <if condition="THIS_SCRIPT != 'arcade' AND THIS_SCRIPT != 'adv_index'"></if> HTML Code: <if condition="!in_array(THIS_SCRIPT, array('arcade', 'adv_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> HTML Code: <if condition="$vbulletin->userinfo['userid'] == 667"> -------------------------------------------------- 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> -------------------------------------------------- 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="$foruminfo['forumid'] == X"></if> HTML Code: <if condition="$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> HTML Code: <if condition="in_array($forumid, array(1,2,3,6))"> -------------------------------------------------- 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 conditional="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 user the thread starter? -------------------------------------------------- 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>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#2
| ||||
| ||||
| 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> -------------------------------------------------- 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> -------------------------------------------------- You can use this conditional to display something if registration is enabled on the board. HTML Code: <if condition="$show['registerbutton']"></if> -------------------------------------------------- You can use this conditional to display something if memberlist is enabled/viewable on the board. HTML Code: <if condition="$vboptions['enablememberlist']"></if> -------------------------------------------------- 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> -------------------------------------------------- You can use this conditional to display something if Style choosing dropdown is enabled/viewable in footer HTML Code: <if condition="$show['quickchooser']"></if> -------------------------------------------------- You can use this conditional to display something if language choosing is enabled. HTML Code: <if condition="$show['languagechooser']"></if> -------------------------------------------------- You can use this conditional to display something if "Contact Us" is enabled. HTML Code: <if condition="$show['contactus']"></if> -------------------------------------------------- You can use this conditional to display something if "AdminCP" is enabled (or is administrator) HTML Code: <if condition="$show['admincplink']"></if> -------------------------------------------------- You can use this conditional to display something if "ModCP" is enabled (or is Super Moderator) HTML Code: <if condition="$show['modcplink']"></if>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#3
| ||||
| ||||
|
Thanks For THis List *Speaks to everyone* Please thank Admin for these
__________________ My iPhone is better than yours........... I Am Back! |
|
#4
| ||||
| ||||
|
thanks for the information.... great...
|
|
#5
| ||||
| ||||
|
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? |
|
#6
| ||||
| ||||
|
hmm.. Thread Starter conditional. ok, try this. HTML Code: <if condition="$thread['postuserid'] == $bbuserinfo['userid'] && $thread['firstpostid'] = $bbuserinfo['userid']"> 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']">
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#7
| ||||
| ||||
|
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? |
|
#8
| ||||
| ||||
|
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>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#9
| ||||
| ||||
|
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. |
|
#10
| ||||
| ||||
|
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 ??
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#11
| ||||
| ||||
As Said by webwizzy 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? |
|
#12
| ||||
| ||||
|
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. |
|
#13
| ||||
| ||||
| 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.
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#14
| ||||
| ||||
|
Thank you for the explanation, as well as the link. I will take a look at it in a few.
|
|
#15
| ||||
| ||||
|
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 --> 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>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#16
| ||||
| ||||
|
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. |
|
#17
| ||||
| ||||
|
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 !
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#18
| ||||
| ||||
|
great list ^_^ thanks
|
|
#19
| ||||
| ||||
|
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>
__________________ Would you like to Link To Us | Support TECH6 by going Premium Know more about me at Vinayaks.com | Follow TECH6 at Twitter |
|
#20
| ||||
| ||||
|
thanx this really amazing man, :d i love you for this
|
![]() |
| Bookmarks |
| Tags |
| template conditionals, vbulletin |
| Thread Tools | |
| Display Modes | |
| |