Re: [PHP Template] Re:comments on the template engine example document

From: Date: Thu, 23 Mar 2000 16:49:48 +0000
Subject: Re: [PHP Template] Re:comments on the template engine example document
References: 1 2 3  Groups: php.template 
Request: Send a blank email to php-template+get-448@lists.php.net to get a copy of this message
On Thu, 23 Mar 2000, jm wrote: > First, would it be possible to use > <!-- tplrem here a template comment --> > so that a WYSIWIG tool for working on the template does get confused about it, > and don't mess the whole layout ? > > Same remark does also apply to the {section} keyword. Yes, you can use either { and } as delimiters, or <!-- { and } -->. So you could do: <!-- {* comment *} --> <!-- { section name="blah" }--> > Another BIG thing is: > Can section be named ? so more than one can be used in the same template Of course. It's even possible for several sections to have the same name. > What I would usually do is use the same template for the 3 cases, > using 3 sections > > > <table> > <!-- section name="no_data" --> > <tr><td> No data please try again <td></tr> > <!-- section end --> > <!-- section name="one_record" --> > <tr><td> Welcome {$name} here is your password {$pwd} <td></tr> > <!-- section end --> > <!-- section name="choose_record" --> > <tr><td> There is more than one person fitting your criteria, please choose > one </td></tr> > <!-- section name="people_record" --> > <tr><td> <a > href="whatever.php?id={$id}">{$name}</a></td></tr> > <!-- section end --> > <tr><td> table footnote if you want <td></tr> > <!-- section end --> > </table> > > And in the php code, you basically activate one of the three main section. > That is the way we do use templates, and keep logic in the code... > templ("no_data").activate > > By default the template engine does clear all section NOT activated. This is already possible in the current specification. You can use tmpl_show_section() function to control the display of sections. I just need to figure out how to do it inside another section loop.. > One stuff that might be useful is some kind of "scope" for the variables, > in order to tell in what loop section it does belongs... What do you mean? > Using multiple sections allow to keep all the logic in the php code, have > just one file for all the cases and give as much freedom as possible to the > designers > (and yes, sometimes the designers gave feedback or requirement for the > design and the template and the logic are changed) > > I hope my example was clear... > I found that quite powerful and therefore my rejection of "logic" stuff > directly in the template. Like I said, the engine is pretty flexible. You can do your conditionals using sections controlled from PHP script or you can do an occasional 'if'. > Another thing you might want to consider is that > not all people are native english speaker and a > {section} > {alternate} > {/section} > is as complicated for them as some php code. Well, {alternate} is about the best I could come up with. If you have a better suggestion, please let us know. -Andrei * Black holes are where God divided by zero. *

« previous php.template (#448) next »