Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

{if $tempValue != ($tempValue = $iProductId)}

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
Karel S.
Smarty Rookie


Joined: 03 Aug 2009
Posts: 26
Location: The Netherlands

PostPosted: Tue Sep 01, 2009 2:22 pm    Post subject: {if $tempValue != ($tempValue = $iProductId)} Reply with quote

This always worked in Smarty 2, but seems to be broken in 3:

Code:

{assign var="tempValue" value=""}
{foreach from=$aProducts item="aData" key="iProductId"}

{if $tempValue != ($tempValue = $iProductId)}
//do something extra
{/if}

{/foreach}
Back to top
View user's profile Send private message
Karel S.
Smarty Rookie


Joined: 03 Aug 2009
Posts: 26
Location: The Netherlands

PostPosted: Tue Sep 01, 2009 2:35 pm    Post subject: Reply with quote

This works fine:

Code:

{assign var="tempValue" value=""}
{foreach from=$aProducts item="aData" key="iProductId"}

{if $tempValue != $iProductId}
//do something extra
{/if}

{$tempValue = $iProductId}
{/foreach}
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Tue Sep 01, 2009 3:35 pm    Post subject: Reply with quote

Code:
{if $tempValue != ($tempValue = $iProductId)}
//do something extra
{/if}


does in my place create in Smarty2 a syntax error...
Are you shure that it did work in Smarty2?
Back to top
View user's profile Send private message
Karel S.
Smarty Rookie


Joined: 03 Aug 2009
Posts: 26
Location: The Netherlands

PostPosted: Wed Sep 02, 2009 6:55 am    Post subject: Reply with quote

Yes, it always worked. This is the code:

Code:

{assign var="tempName" value=""}
{foreach from=$aProducts item="aData" key="sCategoryName"}
{if $tempName != ( $tempName = $sCategoryName )}
            <h4>{$sCategoryName|escape}</h4>
{/if}
            <ul>
{foreach from=$aData item="aProduct"}
                  <li class="left">{print data}</li>
                  <li class="right">{print data}</li>
{/foreach}
            </ul>
{/foreach}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP