|
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 |
Greatness Smarty n00b
Joined: 07 May 2014 Posts: 2
|
Posted: Wed May 07, 2014 7:55 am Post subject: Question about iteration is div by in a foreach loop |
|
|
Hello everyone, I just signed up here and I'm pretty new to smarty but trying my best to teach myself step by step. I've got a weird problem currently with my foreach loop and I was hoping to get some feedback here.
Well I've got this...
Code: |
<ul>
{foreach name=aussen item=module_data from=$product_listing}
<li>item</li>
<li>item</li>
...
{/foreach
</ul>
|
...and I wanted to to insert a banner after every 6th item (it's a product listing). I've added the following code in my foreach loop...
Code: |
{if $smarty.foreach.aussen.iteration is div by 7}
<img>
{/if}
|
...which almost works BUT... when i look at my source code it first gets added after the 6th item (which is correct), the second time it gets added after the 7th item. does it count the first item that got added in the loop? if yes, how would it be possible to fix that?
I'm sorry for the worse explanation and crappy english but I hope you understand what I'm trying to say |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu May 08, 2014 4:03 am Post subject: |
|
|
iteration starts at 1, but index starts at 0.
the following should work.
Code: | {if $smarty.foreach.aussen.index is div by 6}
<img>
{/if} |
|
|
Back to top |
|
Greatness Smarty n00b
Joined: 07 May 2014 Posts: 2
|
Posted: Thu May 08, 2014 6:23 am Post subject: |
|
|
Hey, thanks for the swift response. I've tested it a few minutes ago and it works perfectly. Thanks a lot! |
|
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
|