Re: section title block

From: Date: Mon, 26 Feb 2001 14:50:32 +0000
Subject: Re: section title block
References: 1 2 3 4 5 6  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-230@lists.php.net to get a copy of this message
Andrei Zmievski wrote: > > On Mon, 26 Feb 2001, Monte Ohrt wrote: > > 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. > > How likely is it that different sections will have the same > header/footer? Not very much, I think. Well, the obvious case would be HTML tables. Anytime you use a section to loop through html table rows, you will want to have <TABLE ...> at the top and </TABLE> at the bottom. Quite reusable I think. Just pass your table parameters to the first include. example: section_header.tpl ------------------ <TABLE {if $border ne ""}border=$border{/if} {if $bgcolor ne ""}bgcolor=$bgcolor{/if}> section_footer.tpl {/TABLE} Then call like this: {section name=mystuff loop=$data} {include name="section_header.tpl" show=%mystuff.first% border="0" bgcolor="#ffffff"} {* row data *} {include name="section_footer.tpl" show=%mystuff.last%} {/section} > > > 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. > > I don't see a big need for header/footer stuff either - I was just > replying to the original poster. Personally, a single {if count($foo) > > 0)} around the whole section seems to be clean enough. > > -Andrei > * Power corrupts. Atomic power corrupts atomically. * -- Monte Ohrt <monte@ispi.net> http://www.ispi.net/

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