smarty nested if condition is not working properly?

3.4k Views Asked by At

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

There are 1 best solutions below

0
On

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.