Page 1 of 1

Smarty generation help

Posted: Thu Jul 02, 2015 7:08 pm
by Recon
Hi,

I have tried to generate CGblog articles in summary template that there are specific html <row> one in three line.

This is what I want to generate:

Code: Select all

<div class="row">

<div class="item">
</div>

<div class="item">
</div>

<div class="item">
</div>

</div> <!-- end row -->

This is how I have tried to do it:

Code: Select all

{foreach from=$items item=entry name='foo'}

{if $smarty.foreach.foo.index is div by 3}
<div class="row">
{/if}

<div class="item">
</div>

{if $smarty.foreach.foo.iteration is div by 3}
</div>
{/if}

{/foreach}

But no. It won't work like this.

Re: Smarty generation help

Posted: Thu Jul 02, 2015 8:16 pm
by velden
Read this (it's Dutch, but read the code examples and links to more info):
http://forum.cmsmadesimple.org/viewtopi ... 16#p318616

And try this (untested)

Code: Select all

<div class="row">
{foreach from=$items item=entry}

<div class="item">
</div>

{if $entry@iteration is div by 3 and not $entry@last}
</div>
<div class="row">
{/if}
{/foreach}
</div>

Re: Smarty generation help

Posted: Mon Jul 06, 2015 6:54 am
by Recon
Perfect!

Thank you.

-R