Limiting the section loop

From: Date: Thu, 21 Jun 2001 09:17:41 +0000
Subject: Limiting the section loop
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-923@lists.php.net to get a copy of this message
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

« previous php.smarty.general (#923) next »