Re: The use of templates

From: Date: Wed, 14 Feb 2001 11:48:13 +0000
Subject: Re: The use of templates
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-124@lists.php.net to get a copy of this message
You don't have to use the Smarty template language. It is possible to create different (nested) templates, and use while loops in the php code. However you will end up in much more templates and more php code, and because of the many templates, more difficult to understand than one template with the simple Smarty template language. E.g. instead of a template like this: A list of names: {section name=people loop=$FirstName} {$people/FirstName}<br> {/section} End of list you can create two templates like this (bodytemplate.tpl): A list of names: {$names} End of list And (namestemplate.tpl): {$FirstName}<br> With the corresponding php code (example): while ($db->next_record()) { $namestemplate->assign("FirstName",$db->f["FirstName"]); $names .= $namedtemplate->fetch("namestemplate.tpl"); } $bodytemplate->assign("names",$names); $bodytemplate->display("bodytemplate.tpl"); We think that it is much better to use the Smarty language. It's easy to understand, and designers who know html don't have troubles with the Smarty language. However, you don't have to... It's up to you. Regards, Joris NL

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