smarty nested if condition is not working properly

2019-07-19 01:03发布

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条回答
老娘就宠你
2楼-- · 2019-07-19 02:04

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.

查看更多
登录 后发表回答