Re: The use of templates

From: Date: Tue, 20 Feb 2001 06:06:50 +0000
Subject: Re: The use of templates
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-162@lists.php.net to get a copy of this message
As Joris points out, you can make the template language as simple or complex as you like. You don't like loops in the template? Fine, include a bunch of separate template files from the PHP code like you are saying... although I really don't see the benefit of this, because now the template designers must keep track of a bunch of different files for repeating data. Less complex? It is much easier to learn a few simple template constructs IMHO. As for performance, I don't really see much of a difference either way since everything runs as PHP scripts anyways. Alain Fontaine wrote: > Joris, > > Thanks for your reply; your suggested solution looks good. How about > performance? Although my application is not performance-critical, I'm > interested in what would be faster, and what the difference in speed would > be? > > Thanks ! > > > -----Message d'origine----- > > De : Joris Trooster / Interstroom [mailto:trooster@interstroom.nl] > > Envoyé : mercredi 14 février 2001 12:48 > > À : smarty@lists.ispi.net > > Objet : [smarty] Re: The use of templates > > > > > > > > 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 > > > > > > --- > > You are currently subscribed to smarty as: alain@nvision.lu > > To unsubscribe send a blank email to $subst('Email.Unsub') > > Visit Smarty's homepage at /ÛB > > âbÞkݹ[chttp://www.phpinsider.com/php/code/Smarty/ > > --- > You are currently subscribed to smarty as: monte@ispi.net > 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 (#162) next »