|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Karel S. Smarty Rookie
Joined: 03 Aug 2009 Posts: 26 Location: The Netherlands
|
Posted: Tue Sep 01, 2009 2:22 pm Post subject: {if $tempValue != ($tempValue = $iProductId)} |
|
|
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 |
|
Karel S. Smarty Rookie
Joined: 03 Aug 2009 Posts: 26 Location: The Netherlands
|
Posted: Tue Sep 01, 2009 2:35 pm Post subject: |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Sep 01, 2009 3:35 pm Post subject: |
|
|
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 |
|
Karel S. Smarty Rookie
Joined: 03 Aug 2009 Posts: 26 Location: The Netherlands
|
Posted: Wed Sep 02, 2009 6:55 am Post subject: |
|
|
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 |
|
|
|
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
|