Re: [SMARTY] To who's right is right??
| From: | Monte Ohrt | Date: | Mon, 17 Jun 2002 13:34:09 +0000 |
| Subject: | Re: [SMARTY] To who's right is right?? | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-4901@lists.php.net to get a copy of this message | ||
Rule of thumb: display/formatting logic goes in the template, all other logic goes in your application. So in PHP do your db query and assign the content to template, then format it there. If the data is repetitive, loop through your data in the template to display it in a table, etc.
The template editor should _not_ have to go into the PHP application to make a change to the display of the content.
Gerard Samuel wrote:
Well I finally got my hands dirty with smarty (and using templates at that) this weekend. Its was way easier that what I originally thought. At first, I was using logic within the templates to determine what to display. Then I thought to myself, why am I determining what to present in 2 places (php code & smarty). Ex 1 Determining what to display when a user is a registered user. Ex 2 Run a database loop to fill and array and then do another loop to display it in smarty. So I went back and redid how things were done and have php decide what to display, while Smarty piece the chunks of template code together to form the document. For example, database loops, as soon as I get the info from the database, I assign and display it, instead of going through 2 loops to display content. The bottom line, is there a right way or a wrong way to use smarty? Would I be penalised for not using smarty's logic routines? As this was my first time ever using a template engine, I didn't want to get too deep into it, and find out that Im doing things the wrong way. Thanks for any input you may provide.-- Monte Ohrt <monte@ispi.net> Director of Technology, ispi Inc.