Re: section title block

From: Date: Mon, 26 Feb 2001 14:39:06 +0000
Subject: Re: section title block
References: 1 2 3 4  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-228@lists.php.net to get a copy of this message
Andrei Zmievski wrote: > > On Sun, 25 Feb 2001, Monte Ohrt wrote: > > BUT, here comes an entirely different approach... how about we add a > > boolean parameter to the {include ...} statement, making the include > > conditional. for example: > > > > {section name=mystuff loop=$data} > > > > {include file="section_header.tpl" show=%mystuff.first%} > > > > {* put section rows here *} > > > > {include file="section_footer.tpl" show=%mystuff.last%} > > > > {/section} > > > > > > We'll add to Smarty the entities %section.first% and %section.last%, > > being true/false depending on the section iteration. We'll also add the > > boolean flag "show" (or whatever name is decided) to the include > > function, default being true of course. > > > > This solves several things, first that come to mind: > > > > * still understandable syntax to designers > > * modularizes the template, so section headers/footers are reusable (can > > pass parameters, whatever) > > * We don't add new syntax to the template engine, keeping smarty a bit > > leaner > > * very easy to implement :-) > > I don't think this would be too helpful. Now you have to split your > section header/footer items into another template file - gets kind of > messy after a while. If we can't implement sectionheader/sectionfooter > directly (like I said, this may be difficult with the current parser), > then we shouldn't try to go for workarounds like this either. > > -Andrei > * Black holes are where God divided by zero. * To each their own I guess. I don't think of this as a workaround, I think of it as an added feature to be able to do something like this. This makes the section header/footer reusable, which would be likely in any case. If you really don't want to split your content out into separate templates, you can still use {if} statements: {section name=mystuff loop=$data} {if %mystuff.first%} <TABLE border=0> {/if} {* row data *} {if %mystuff.last%} </TABLE> {/if} {/section} Personally, I think making up new section tag names is a "workaround" and clutters the template syntax even more than this solution. -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

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