Re: Limiting the section loop
| From: | Monte Ohrt | Date: | Thu, 21 Jun 2001 14:57:02 +0000 |
| Subject: | Re: Limiting the section loop | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-929@lists.php.net to get a copy of this message | ||
you can impose a limit by using a number for the loop value.
{* hard coded *}
{section name=foo loop=7}
{* from a config_file *}
{section name=foo loop=#loop_max#}
Anders Janson wrote:
>
> Hi !
>
> A new attribute "limit" (or whatever) for the template sections would be
> nice.
> My application presents data using several Smarty templates. One
> template might display all data items, whereas another template uses
> only the first 5 or so. I don't want to bother my application code with
> these presentation details, of course, so I want to put the loop
> restrictions in the templates.
>
> Using "if" statements to check if the loop count is above my limit value
> works, but makes the templates really ugly. It means putting code in the
> presentation, and I prefer to keep that to a minimum.
>
> A much neater way would be to write something like:
> {section name=foo loop=$bar limit=7}
>
> And for compatibility, "limit" should be optional, with a default of
> "all".
>
> Anyone agrees?
>
> /Anders Janson
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/