Re: [SMARTY] migrating to Smarty..

From: Date: Tue, 25 Feb 2003 03:10:59 +0000
Subject: Re: [SMARTY] migrating to Smarty..
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8164@lists.php.net to get a copy of this message
Hi Jun, IIRC, one of the main reasons that you included templates repeatedly was for doing things like outputting an array into a table, i.e. you would have a "sub-template" for each <tr><td>...</td></tr> and include it many times. The "Smarty" way of handling this kind of construct is to pass the entire array into the template and loop over it using a section. Your template might look like: <table> {section name=d loop=$data} <tr><td>{$data[d].rowid}</td><td>{$data[d].name}</td></tr> {/section} </table> You would then have only the single template, and much less display logic embedded in you php script. Smarty also has a feature that I believe more directly correlates with your existing usage pattern, the Smarty::fetch() method. You can assign values to a template, fetch it into another variable, then assign it to another template. HTH Jason ----- Original Message ----- From: "Jun" <juney20@yahoo.com> To: <smarty-general@lists.php.net> Sent: Monday, February 24, 2003 8:26 PM Subject: Re: [SMARTY] migrating to Smarty.. > ok thanks! I'll work it out > > "Messju Mohr" <messju@lammfellpuschen.de> wrote in message > news:20030224170529.GU22684@pharao.lammfellpuschen.de... > > On Tue, Feb 25, 2003 at 12:24:55AM +0800, Jun wrote: > > > Hi! I'm a fasttemplate user. I want to migrate to Smarty, but the > > > documentation is insufficient to convince me that smarty is easier than > > > FastTemplate... What is the equivalent of FT's nested template where, > you > > > can parse a certain template and assign the returned "tags" to another > > > template variable... sort of, combining more than templates to create a > > > single page. > > > > {include file="template.tpl" assign="var"} > > > > explained in > > > > http://smarty.php.net/manual/en/language.function.include.php > > > > have fun > > messju > > > > > Is there a good reference for Smarty newbies... hopefully with > > > friendly explanations,step by step... > > > > > > thank you > > > jun > > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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