The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Simple IF Question
Ok, Im basically editing my postbit and I need to know how to write an IF statement based on a registration question (user profile field).
The question is "What system do you primarly play on". Its a radio box with 2 choices: "Xbox 360 and Playstation 3". That question is followed by another single line textbox question asking for either Xbox Gamertag or PSN ID. Now from there Im trying to edit my postbit to display either their xbox gamertag or psn id depending on how thy answered the question. So, I need to know how to write the IF statement in the postbit. I need a statement like: <If condition = "[fieldXX] = Xbox 360"> Can anyone help me with the proper code to write out to basically say "if the answer to feildX is Xbox 360". I know what to do from there but I havnt edited or seen any code dealing with an IF based on a user profile field answer. Thank you in advance for taing the time togive me any input you can. |
#2
|
||||
|
||||
HTML Code:
<if condition="post['fieldxxx']"><img src="path.to.image/$post[fieldxxx].gif" alt="" /> HTML Code:
</if>
For example: - AdminCP = "Xbox 360" (without the quotes) - Image = "Xbox 360.gif" (without the quotes) |
#3
|
|||
|
|||
What I need though is a IF statement dependng on the answer to the question, something like:
HTML Code:
<if condition="post['fieldxxx'] ='Xbox 360'"><img src="path.to.image/$post[fieldxxx].gif" alt="" /> Thank you for your input though, but I need an IF that says "if the answer is A, display this image, else if the answer is B display this image". |
#4
|
|||
|
|||
You need to use == and not = inside if statements.
As you want to compare right hand side with left hand side, and not set right hand side to left hand side. Example: a = 5 + 6; This means that a is set to be 5+6 which is 11, so a will be 11 a == 5 + 6; This checks the value of a to see if it is the value of 5 + 6. So you should try this: HTML Code:
<if condition="post['fieldxxx'] == 'Xbox 360' "> <img src="path.to.image/$post[xbox].gif" alt="" /> <else /> <!-- User must have picked PS3 --> <img src="path.to.image/$post[ps3].gif" alt="" /> </if> HTML Code:
<if condition="post['fieldxxx'] == 'Xbox 360' "> <img src="path.to.image/$post[xbox].gif" alt="" /> <else /> <if condition="post['fieldxxx'] == 'PS3' "> <img src="path.to.image/$post[ps3].gif" alt="" /> <else /> <img src="path.to.image/$post[pc].gif" alt="" /> </if> </if> Found it on the vBulletin Manual HERE |
#5
|
|||
|
|||
Thank you for your reply and thetime to took to answer my question. I'll test it out this week.
|
#6
|
|||
|
|||
I tested the code and it gave me an error message:
Quote:
HTML Code:
<if condition="post['field9'] == 'Xbox 360' "> <td class="alt2" align="left" valign="top"><iframe src="http://gamercard.xbox.com/$post[field10].card" scrolling="no" frameBorder="0" height="95" width="204">$post[field10]</iframe></td> </if> <if condition="post['field9'] == 'Playstation 3' "> <td class="alt2" align="left" valign="top"><a href="http://www.us.playstation.com/PSN/Users/$post[field33]"><img src="http://pid.us.playstation.com/user/$post[field33].jpg" width="235" height="149" border="0" /></a></td> </if> PHP Code:
Can someone help me out, doesn seem like that hard of a question, lol. Baically just need something along the lines of: HTML Code:
<if condition="post['field9'] == 'Xbox 360' ">
Thanks goes to those who take the time to reply to a VB newbie. |
#7
|
||||
|
||||
Try this
HTML Code:
<if condition="post[field9] == 'Xbox 360' "> <td class="alt2" align="left" valign="top"> <iframe src="http://gamercard.xbox.com/$post[field10].card" scrolling="no" frameBorder="0" height="95" width="204">$post[field10] </iframe> </td> </if> <if condition="post[field9] == 'Playstation 3' "> <td class="alt2" align="left" valign="top"> <a href="http://www.us.playstation.com/PSN/Users/$post[field33]"> <img src="http://pid.us.playstation.com/user/$post[field33].jpg" width="235" height="149" border="0" alt="" /> </a> </td> </if> |
#8
|
|||
|
|||
Same error:
HTML Code:
The following error occurred when attempting to evaluate this template: Parse error: parse error, unexpected '[' in nameofsite/forums/includes/adminfunctions_template.php(3729) : eval()'d code on line 75 This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish. |
#9
|
|||
|
|||
Quote:
HTML Code:
<if condition="$post[field9] == 'Xbox 360' "> <td class="alt2" align="left" valign="top"> <iframe src="http://gamercard.xbox.com/$post[field10].card" scrolling="no" frameBorder="0" height="95" width="204">$post[field10] </iframe> </td> </if> <if condition="$post[field9] == 'Playstation 3' "> <td class="alt2" align="left" valign="top"> <a href="http://www.us.playstation.com/PSN/Users/$post[field33]"> <img src="http://pid.us.playstation.com/user/$post[field33].jpg" width="235" height="149" border="0" alt="" /> </a> </td> </if> |
#10
|
||||
|
||||
AH!!! I see what I did!! I can't believe I missed that!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|