Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-14-2006, 08:49 AM
Tim Skellett Tim Skellett is offline
 
Join Date: Sep 2005
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Coding question

Hi,
pardon this question (actually two); I'm a complete newbie when it comes to coding.

I would like to modify the following in a vB 3.5.4 template:

<if condition="$show['foo']">

and I would like to modify the above like so:

<if condition="$show['foo']" EXCEPT WHEN [if condition ="$A[X]" AND if condition"$[Y]"]>

or in other words do the operation as normal except when two other conditions are simultaneously met. How best do I code that?

Sorry if I sound painfully dumb; I am indeed a newbie.
______

That's the one question; my next question also refers to the above.
In the above, [Y] has a range of values, so I am looking at some kind of array, I suppose like so:

<if condition="$show['foo']" EXCEPT WHEN [if condition ="$A[X]" AND if condition"$[ARRAY(Y)]"]>

How best do I code that?

______

Many thanks in advance, and please pardon my ignorance.

It occurs to me it would be easier to do a nested "if" set, like so:

Code:
<if condition ="$A[X]" AND if condition"$[ARRAY(Y)]" AND if condition="$show"] show 'alternate'>
     else
             <if condition="$show['foo']" show 'foo'>
             </if>
</if>
Is my coding above correct?

Many thanks in advance for help and patience.
Reply With Quote
  #2  
Old 05-14-2006, 05:01 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Code:
<if condition="$show['foo'] and !$otherVarA and !$otherVarB">
You can seperate multiple conditions with and, or, xor, etc. ! means NOT, so the above condition is true when [ $show['foo'] is true, $otherVarA is false and $otherVarB is false ]
Reply With Quote
  #3  
Old 05-14-2006, 07:40 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Don't use single quotes inside of template conditional varibles.

use $show[foo] instead of $show['foo']
Reply With Quote
  #4  
Old 05-14-2006, 08:29 PM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery
Don't use single quotes inside of template conditional varibles.


use $show[foo] instead of $show['foo']
That is silly and somewhat incorrect:

If foo is a constant, you will run into some problems that will probably take hours to solve. Remember that conditions are parsed like so (NOT in double quotes!):

Code:
blah blah <if condition="$condition">Do this<else />Or Do This</if>blah blah
Code:
blah blah " . ($condition ? "Do This" : "Or Do This") . "blah blah
Example:
PHP Code:
<?php

define
('a''b');

$show['b'] = false;
$show['a'] = true;

echo (
$show[a]) ? 'Working as expected' 'Uh Oh!';

// outputs 'Uh Oh!'
?>
Reply With Quote
  #5  
Old 05-15-2006, 05:15 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by SirAdrian
That is silly and somewhat incorrect:

If foo is a constant, you will run into some problems that will probably take hours to solve. Remember that conditions are parsed like so (NOT in double quotes!):

Code:
blah blah <if condition="$condition">Do this<else />Or Do This</if>blah blah
Code:
blah blah " . ($condition ? "Do This" : "Or Do This") . "blah blah
Example:
PHP Code:
<?php

define
('a''b');

$show['b'] = false;
$show['a'] = true;

echo (
$show[a]) ? 'Working as expected' 'Uh Oh!';

// outputs 'Uh Oh!'
?>
I've always run into problems using single quotes inside of the varibles, and it goes away generally when I remove them.
Reply With Quote
  #6  
Old 05-15-2006, 05:18 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery
I've always run into problems using single quotes inside of the varibles, and it goes away generally when I remove them.
Inside templates you can't use single quotes unless you wrap the variable in braces... In *conditions* though it is not parsed within double quotes. Hope that clears it up.
Reply With Quote
Reply


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 01:40 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05576 seconds
  • Memory Usage 2,227KB
  • Queries Executed 13 (?)
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
  • (6)bbcode_code
  • (2)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete