![]() |
Variables for conditionals
I am just starting to look at using conditionals, and they look like a simple but powerful tool. However you need to know what variables are available and what they do.
Is this documented anywhere? I've looked through the manual and searched on vbulletin.com and here but can't find anything -- have I missed it? Thanks John |
It really depeds on what you want to do. There isn't a list of what variable you can use because you can use anything.
|
As far as I know (which isn't much :D ), there isn't a list of the variables anywhere. Although a single searchable location of all the variables and what they do would be great.
|
Quote:
|
OK, how about something really basic
The variables appear to be in two parts eg $bbuserinfo['userid'] there are also $show $post etc Can anyone start by explaining how this works? Thanks John |
Quote:
$bbuserinfo is a variable array: A variable that can hold multiple values, as opposed to a standard variable that holds only one value. 'userid' is one value in the $bbuserinfo array that is only set if the user is a registered member. So basically "if $bbuserinfo['userid']" is equivelant to saying, "Is the 'userid' value in the $bbuserinfo array set? If yes, then the user is registered". To the best of my knowledge there is no one location where all the standard conditionals are documented here. One developer said it's because there are dozens of variable arrays with hundreds of values each, and as such making a list is just too time consuming for anyone to get to it right now. Or something. :) |
Quote:
$bbuserinfo $vboptions $stylevar Are the 3 globals that i am aware about besides $GLOBAL $bbuserinfo can show anything that is stored in the usertable field for the specific person who is online: IE $bbuserinfo[posts] will show the amount of posts, $bbuserinfo[username] will show a users, username. $vboptions are all the options that are stored in the settings table like to show DHTML or the name of your board or even your bulletin boards url $vboptions[bburl] $vboptions[homeurl] $stylevar holds all the non css style settings, like the image directorys. The problem with the documentation is there are so many vairbles that are possible for all thoughs said templates its hard to just document them. |
A comprehensive list of $vboptions and $stylevar would be dandy.
|
Quote:
|
There's a post here that suggests one way of finding out what is stored in a particular array. As mentioned in that thread, though, you'll only see the output relevant to the current user.
|
Okay, here are the values of my $bbuserinfo array on index.php (I've deleted the actual values for security purposes, and I apologize in advance if posting this code somehow violates any rules here):
Code:
Array |
Quote:
|
Here's the $vboptions array (keeping in mind my board is hacked, so I may have options here that others don't):
Code:
Array |
And $stylevar:
Code:
Array |
good thread, it just helped me
gotta love the search |
functions that can be used with conditionals:
PHP Code:
|
Not sure how posting a list of variables without example values is helpful...
When hacking vB3, I usually PHP Code:
|
User id is say 150
how do I write this in code to find his field20 lets say in his profile. If I use $bbuserinfo it pulls back my (the loged in users) info. I want to pull any users info... this isnt proper code but I want something like this. $onlineuser[userid](field20) just assume $onlineuser acutally pulls the user id of 150 field20 lets say is "Huston" at the end of the day on the HTML page you see HUSTON and it would change for each user. this is for WOL BTW |
Quote:
$bbuserinfo[field20] |
This is very useful, keep up the good work!
|
How about this...
I have a profile field with a dropdown list where a member chooses the state they live in. I want a conditional that says 'if user selected choice #__ in profile field #__.' Thanks. |
Quote:
Code:
<if condition="$var[fieldX]">do stuff</if> $var would be $post or $bbuserinfo or whatever. |
Quote:
and yes that is the conditional HTML Code:
<if condition="$bbuserinfo[fieldX]">Some code here </if> |
I made it so the users must select a choice upon registration. Lets say they chose '7' and the field's ID is '15'... what would be the code to display something for a user with that selected?
|
Quote:
|
Yep, gotta love the search, GREAT thread!
|
Sorry to bump this but:
I want to show code in a certain thread. So I use the threadID How do I define the conditional for a threadid? |
Quote:
SO if say YOU are looking at my page you can see visually my field 20. So I am asking how to pull up.... say... my userid... not yours... (as in bbuser) and find field 20 |
Might be a little late for a reaction but still; I'm wondering if there's also a $post variable available that contains the name of the usergroup as person is in. In fact it would be similar to the "Group:" you got with IPB, I just don't feel like putting up 10 conditionals for every usergroup I've got...
I want to be able to let people edit their usertitle without having trouble with users acting like they're a staffmember. |
This thread is great. Can somone provide a list for the $post array?
|
Same as $bbuserinfo, but just for the person who made the [post.
|
How would I display a user's profile picture inside of a post? I'm having lots of trouble with this.
|
ATM theres no easy way, as in theres no varible. Try making a request.
|
Do I request it here? :)
|
If I were to create the variable, what file / template would I look into?
|
Thanks for all the info!
|
Are there any variables which can tell you where you are on the site?
If a user is viewing one of a number of pages, I want to add additional links to the navbar. After checking the whosonlinebit template I see there is $userinfo[location], but this doesn;t seem to be set in other templates. Any ideas? Thanks |
THIS_SCRIPT is defined on all vBulletin pages (that use templates) I think they are just the name of the file without the .php extension. Therefore your conditional with look like:
Code:
<if condition="THIS_SCRIPT == 'showthread'"> |
thanks, did the trick!
|
good thread, it just helped me
gotta love the search |
All times are GMT. The time now is 02:49 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|