|
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 |
fbronx Smarty Rookie
Joined: 28 May 2003 Posts: 11 Location: Stekene, Belgium
|
Posted: Fri Jan 23, 2004 10:07 am Post subject: looping an include file |
|
|
Wouldn't it be nice to allow looping on included templates?
An example of what I mean:
Code: |
{foreach name=book item=book from=$books}
{if $smarty.foreach.book.first}
<table>
{/if}
{include file="book.tpl"}
{if $smarty.foreach.book.last}
</table>
{/if}
{/foreach} |
book.tpl looks like:
Code: |
<tr>
<td>$book.title</td>
<td>$book.author</td>
</tr> |
Now if we could add looping on include:
Code: | {include file="book.tpl" name=book loop=$books} |
where book.tpl will now look like:
Code: |
{if $smarty.include.book.first}
<table>
{/if}
<tr>
<td>$book.title</td>
<td>$book.author</td>
</tr>
{if $smarty.include.book.last}
</table>
{/if} |
Advantage: Smarty will do the looping now, instead of the designer.
When we could do this, there's no need anymore for a foreach or section statement. |
|
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
|