Home  |  Linux  | Mysql  | PHP  | XML
From:Armen Baghumian Date:Tue Oct 16 04:14:25 2007
Subject:else should not take any arguments
Hi guys,

Several days ago I just had a problem with elseif statement, as it is
specified in documentation these is not any tag called "else if" but I
used that tag and it just executed the else statement and ignored the
if itself.

for example:

{assign var="test" value="blah"}

{if $test != 'blah'}
    Dummy
{elseif $test == 'str'}
    Blah Blah
{/if}

{if $test != 'blah'}
    Dummy2
{else if $test == 'str'}
    Blah2 Blah2
{/if}

which expected output is blank page but it shows "Blah2 Blah2".
Yes this is not smarty bug but it is template designer mistake. IMHO it
is nice to throw an error in such cases then template designer can
correct the mistake.

another example of this situation is:

{if 'blah' != 'blah'}
    Dummy2
{else asdasdasdasdasd asd asdasda}
    Blah Blah
{/if}

as you can saw else ignores any arguments.
I come here with a tiny patch for this situation, it is attached with
this email, hope it could be usefull.

Best Regards,
Armen
Attachment: [text/x-patch] elseif.patch
Navigate in group php.smarty.dev at sever news.php.net
Previous Next


Too many connections

  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants