|
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 |
Fossil Smarty n00b
Joined: 20 Apr 2015 Posts: 1
|
Posted: Mon Apr 20, 2015 1:45 pm Post subject: Need help with 2 column foreach statement |
|
|
Hi,
I've been messing about with a foreach statement for half a day now so I thought I'd come here and ask for help.
I'm using Twitter Bootstrap and have 2 columns side by side like so:
Code: | Column 1 Column 2
Column 3 Column 4
Column 5 Column 6 |
My code is here (filled with dummy data now): http://pastebin.com/jjgW2QCW
Now I want to loop through some SQL results and after every second result there should be a new row with 2 columns
Code: | <!-- Begin Row -->
<div class="row">
2 COLUMNS
</div>
<!-- End Row --> |
Any idea how to do this from within a Smarty .tpl ?
Cheers,
Fossil |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Tue Apr 21, 2015 1:03 am Post subject: |
|
|
Something like this
Code: | {foreach $columns as $column}
{if $column@iteration is odd}<div class="row">{/if}
{$column}
{if $column@iteration is even}</div>{/if}
{/foreach}
{if $column@total is odd}</div>{/if}
|
See the examples in http://www.smarty.net/docs/en/language.function.foreach.tpl |
|
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
|