nay27uk Posted February 27, 2011 Share Posted February 27, 2011 how can you add two {if's} or even three or four. for example if there are three other things enabled on a page then display the number 4 If two of them are enabled but one is disabled display number 3 If only one is enabled then display number 2 What I am trying to do is give each {is statement} on the order forms a step number but am getting confused as what to put if somthing is disabled for example on configureproducts.tpl {$LANG.step} {if $availabilityresults}(from previous page) 5 {else} 4 {/if} - {$LANG.orderconfigure} {$productinfo.description} now the next one down gets confusing because I need to tell it that if {if $availabilityresults}(from previous page) and {if $editconfig} are enabled then display 6 {else} display 5 then it gets even harder each one down I go I have to add another {if} Can anyone please explain a simple way of having each {if statement} on the order forms display the corect number acording to wether somthing is either enabled or disabled. 0 Quote Link to comment Share on other sites More sharing options...
GGWH-James Posted February 27, 2011 Share Posted February 27, 2011 http://www.smarty.net/docsv2/en/language.function.if.tpl The format is more-or-less the same as with standard PHP. 0 Quote Link to comment Share on other sites More sharing options...
nay27uk Posted February 27, 2011 Author Share Posted February 27, 2011 ok thanks james I have tried all of those but like I said I am getting confused. say for example you have 4 things on a page and three are between {if statements} meening that if disabled they will not show on the page but if enabled they show. Now say you have two of those disabled and the other two enabled and on the page they display the text "step1 and Step2 thats fine while the other two are disabled, but you decide one day to enable the other two, now this is wher I need to add if and elses or if's and &&'s so it would be somthing like {if $step2} step 3 {else} step2 It then gets confusing if before the if your working with are more than 2 ifs do you see my point and what I am whishiong to do. I will post the code up I am trying to work with so you can see waht I meen 0 Quote Link to comment Share on other sites More sharing options...
nay27uk Posted February 27, 2011 Author Share Posted February 27, 2011 ok here is my code i am trying to work with what I am trying to do as you will see from the code is name each if with a step number, so if all the things are enabled in admin then they would be named step1 step2 step3 step4 step5 excetera excetera but the problem comes because there are so many {if $statements} if somthing is disabled the next one in line takes that ones step name and so on and so on. I will highlight my {ifs} in red in my code bellow. I am just stumped on what to actualy do here {if $editconfig} <form method="post" action="{$smarty.server.PHP_SELF}?a=confproduct&i={$i}"> <input type="hidden" name="configure" value="true"> {else} <form method="post" action="{$smarty.server.PHP_SELF}?a=add&pid={$pid}"> <input type="hidden" name="configure" value="true"> {/if} <table border="0" cellspacing="0" cellpadding="0" width="100%"> {if $errormessage} <tr class='error'> <td colspan='2'>{$errormessage|replace:'<li>':' # '} # </td> </tr> {/if} {if $productinfo} <tr> <th colspan='2'[color="red"]>{$LANG.step} 5 - {$LANG.orderconfigure} {$productinfo.description}[/color]</th> </tr> <tr class='rowb'> <td width="12%">{$LANG.orderbillingcycle}:</td> <td width="88%">{if $pricing.type eq "free"} <input type="hidden" name="billingcycle" value="free" /> {$LANG.orderfree} {elseif $pricing.type eq "onetime"} <input type="hidden" name="billingcycle" value="onetime" /> {$pricing.onetime} {$LANG.orderpaymenttermonetime} {else} <select name="billingcycle" onchange="submit()"> {if $pricing.monthly}<option value="monthly"{if $billingcycle eq "monthly"} selected="selected"{/if}>{$pricing.monthly}</option>{/if} {if $pricing.quarterly}<option value="quarterly"{if $billingcycle eq "quarterly"} selected="selected"{/if}>{$pricing.quarterly}</option>{/if} {if $pricing.semiannually}<option value="semiannually"{if $billingcycle eq "semiannually"} selected="selected"{/if}>{$pricing.semiannually}</option>{/if} {if $pricing.annually}<option value="annually"{if $billingcycle eq "annually"} selected="selected"{/if}>{$pricing.annually}</option>{/if} {if $pricing.biennially}<option value="biennially"{if $billingcycle eq "biennially"} selected="selected"{/if}>{$pricing.biennially}</option>{/if} {if $pricing.triennially}<option value="triennially"{if $billingcycle eq "triennially"} selected="selected"{/if}>{$pricing.triennially}</option>{/if} </select> {/if}</td> </tr> </table> {/if} <br /> {if $productinfo.type eq "server"} <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <th colspan='2'>[color="red"]{$LANG.step}{if $editconfig} 6 {else} 5 {/if} - {$LANG.cartconfigserver}</[/color]th> </tr> <tr class='rowb'> <td width="15%">{$LANG.serverhostname}</td> <td width="85%"><input type="text" name="hostname" size="15" value="{$server.hostname}" /> eg. server1(.yourdomain.com)</td> </tr> <tr class='rowa'> <td width="15%">{$LANG.serverns1prefix}:</td> <td width="85%"><input type="text" name="ns1prefix" size="10" value="{$server.ns1prefix}" /> eg. ns1(.yourdomain.com)</td> </tr> <tr class='rowb'> <td width="15%">{$LANG.serverns2prefix}:</td> <td width="85%"><input type="text" name="ns2prefix" size="10" value="{$server.ns2prefix}" /> eg. ns2(.yourdomain.com)</td> </tr> <tr class='rowa'> <td width="15%">{$LANG.serverrootpw}:</td> <td width="85%"><input type="password" name="rootpw" size="20" value="{$server.rootpw}" /></td> </tr> </table> <br /> {/if} {if $configurableoptions} <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <th colspan='2'> {[color="red"]$LANG.step}{if $editconfig && $productinfo.type eq "server"} 7 {else} 6 {/if}- {$LANG.orderconfigpackage}[/color] </th> </tr> {foreach key=num item=configoption from=$configurableoptions} <tr class='rowb'> <td width="12%">{$configoption.optionname}:</td> <td width="88%">{if $configoption.optiontype eq 1} <select name="configoption[{$configoption.id}]"> {foreach key=num2 item=options from=$configoption.options} <option value="{$options.id}"{if $configoption.selectedvalue eq $options.id} selected="selected"{/if}>{$options.name}</option> {/foreach} </select> {elseif $configoption.optiontype eq 2} {foreach key=num2 item=options from=$configoption.options} <input type="radio" name="configoption[{$configoption.id}]" value="{$options.id}"{if $configoption.selectedvalue eq $options.id} checked="checked"{/if}> {$options.name}<br /> {/foreach} {elseif $configoption.optiontype eq 3} <input type="checkbox" name="configoption[{$configoption.id}]" value="1"{if $configoption.selectedqty} checked{/if}> {$configoption.options.0.name} {elseif $configoption.optiontype eq 4} <input type="text" name="configoption[{$configoption.id}]" value="{$configoption.selectedqty}" size="5"> x {$configoption.options.0.name} {/if} </td> </tr> {/foreach} </table> <br /> {/if} {if $addons} <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <th colspan='2'> [color="red"]{$LANG.step}{if $editconfig && $productinfo.type eq "server" && $configurableoptions} 8 {else} 7 {/if} - {$LANG.orderchooseaddons}[/color] </th> </tr> {foreach key=num item=addon from=$addons} <tr class='rowb'> <td>{$addon.checkbox} <strong>{$addon.name}</strong> - {$addon.description} ({$addon.pricing})</td> </tr> {/foreach} </table> <br /> {/if} {if $customfields} <table border="0" cellspacing="0" cellpadding="0" width="100%"> <tr> <th>{$LANG.step} 9 - {$LANG.orderadditionalrequiredinfo}</th> </tr> {foreach key=num item=customfield from=$customfields} <tr class='rowb'> <td>{$customfield.name}: {$customfield.input} {$customfield.description}</td> </tr> {/foreach} </table> {/if} 0 Quote Link to comment Share on other sites More sharing options...
nay27uk Posted February 27, 2011 Author Share Posted February 27, 2011 I have given up on this now and just added the step number to the top of the page 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.