Re: Arguments for Smarty

From: Date: Fri, 07 Dec 2001 16:45:03 +0000
Subject: Re: Arguments for Smarty
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-2201@lists.php.net to get a copy of this message
Thanks Monte, What of my other comments in my original post? Thank you for you time. Pablo -----Original Message----- From: mohrt@ns3.ispi.net [mailto:mohrt@ns3.ispi.net]On Behalf Of Monte Ohrt Sent: Friday, December 07, 2001 10:46 AM To: smarty@lists.ispi.net Cc: smarty@lists.ispi.net Subject: [smarty] Re: Arguments for Smarty Pablo wrote: > > For example, coming from the PHPLIB templates we used to use, the way you > show database results is to assign each record one at a time using blocks. > So you are rendering each line of the result set and that means that > resource requirements are significantly less (to be fair, it depends on how > you handle the templates and parsing. A bad programmer could get back to > the 10,000 x 1K memory issue above). I don't see functionality from Smarty > to do this. It seems to be an all-or-nothing proposition when you do > sections. You need to send ALL the data to the template and it loops > through the array. Is there some "block" type functionality that will let > the looping happen inside the PHP file and call a smarty template per > record? I am thinking yes, but it means you would need to render the header > first, then the records, then the footer. ?? > You can do several things. You can use the append() function in Smarty to loop through your data and accumulate it row by row as you query your database (although it is a bit more efficient to assign everything in one go). It is up to you to grab the subset of data you need for the template. If you really like the PHPLib way of appending and accumulating template blocks, by all means go ahead! You can do it, we just don't encourage the practice or show examples. Something like this: index.php --------- // query db and get results while($sql->next) { $smarty->assign($sql->record); $rowdata .= $smarty->fetch("row.tpl"); } $smarty->assign("rowdata",$rowdata); $smarty->display("index.tpl"); row.tpl ------- <tr><td>{$var1}</td><td>{$var2}</td><td>{$var3}</td></tr> index.tpl --------- {include file="header.tpl"} <table> {$rowdata} </table> {include file="footer.tpl"} --- You are currently subscribed to smarty as: phpshop@phpshop.org To unsubscribe send a blank email to $subst('Email.Unsub') Visit Smarty's homepage at http://www.phpinsider.com/php/code/Smarty/

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