smarty nested if condition is not working properly?

橙三吉。 提交于 2019-12-11 02:12:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!