Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2009, 11:01 PM
Cledus James Cledus James is offline
 
Join Date: Oct 2008
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 06-26-2009, 11:06 PM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HTML Code:
<if condition="post['fieldxxx']"><img src="path.to.image/$post[fieldxxx].gif" alt="" />
HTML Code:
</if>
Now, the images you're using for "fieldxxx" must be named, exactly how you have them named in the AdminCP.

For example:
- AdminCP = "Xbox 360" (without the quotes)
- Image = "Xbox 360.gif" (without the quotes)
Reply With Quote
  #3  
Old 06-28-2009, 02:32 PM
Cledus James Cledus James is offline
 
Join Date: Oct 2008
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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="" />
But of course "= 'Xbox 360'" doesnt work.

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".
Reply With Quote
  #4  
Old 06-28-2009, 03:37 PM
Webmaster961 Webmaster961 is offline
 
Join Date: Jan 2005
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Of course you could also incorporate more platforms like this:

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>
That should work, but I haven't tested it.

Found it on the vBulletin Manual HERE
Reply With Quote
  #5  
Old 06-28-2009, 04:09 PM
Cledus James Cledus James is offline
 
Join Date: Oct 2008
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for your reply and thetime to took to answer my question. I'll test it out this week.
Reply With Quote
  #6  
Old 06-30-2009, 11:16 PM
Cledus James Cledus James is offline
 
Join Date: Oct 2008
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tested the code and it gave me an error message:

Quote:
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 74

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.
Line 74 is the first IF statement. The code I used was:

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>
I also tested it with just IF statements and it still didnt work on so the problem is with them, not the output. I also tested the output of
PHP Code:
$post[field9
and it had the right anseers, Xbox 360 or Playstation 3.

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' ">
Field9 is is a user profile field question with radio buttons with 2 selections as answers: Xbox 360 or Playstation 3.

Thanks goes to those who take the time to reply to a VB newbie.
Reply With Quote
  #7  
Old 06-30-2009, 11:31 PM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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>
Reply With Quote
  #8  
Old 07-01-2009, 03:58 AM
Cledus James Cledus James is offline
 
Join Date: Oct 2008
Posts: 79
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Line 75 is the first IF statement. Anymore ideas? lol
Reply With Quote
  #9  
Old 07-01-2009, 04:03 AM
toonysnn toonysnn is offline
 
Join Date: Sep 2006
Location: Texas
Posts: 511
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Redlinemotorsports View Post
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>
Almost right.
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>
Reply With Quote
  #10  
Old 07-01-2009, 04:20 AM
HMBeaty's Avatar
HMBeaty HMBeaty is offline
 
Join Date: Sep 2005
Posts: 4,141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

AH!!! I see what I did!! I can't believe I missed that!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.13162 seconds
  • Memory Usage 2,278KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (11)bbcode_html
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete