问题
I have written my code like this,
{if $quant eq 1}
{if $val neq ""}
.....//some code
{else}
.....//some code
{/if}
{else if $quant eq 0}
.....//some code
{/if}
but the above nested smarty if condition is not working as expected and it always give the results in else condition.Can anyone help me please, Don't know where am making mistake...
回答1:
In smarty you have to write if else condition like that:
{if $quant eq 1}
{elseif $val neq ""}
.....//some code
{elseif $val neq "3"}
.....//some code
{elseif $quant eq 0}
.....//some code
{/if}
OR
{if $quant eq 1}
{if $val neq ""}
.....//some code
{else}
.....//some code
{/if}
{else}
{if $quant eq 0}
.....//some code
{/if}
.....//some code
{/if}
I hope this would help you.
来源:https://stackoverflow.com/questions/18527644/smarty-nested-if-condition-is-not-working-properly