Re: nested template question

From: Date: Tue, 27 Mar 2001 09:16:49 +0000
Subject: Re: nested template question
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-444@lists.php.net to get a copy of this message
The subject says your templates are nested while in fact they are not. The manual says the section names must be unique in case of nested sections. Therefore in your case the section names need not be unique, they can have the same name, right?. So, wouldn't be the following the solution? item.tpl: <a href="{$mysection/url}">{$mysection/name}</a> index.tpl: My bookmarks: {section name=mysection loop=$mybookmarks} {include file="item.tpl} {/section} <br><br>Your bookmarks: {section name=mysection loop=$yourbookmarks} {include file="item.tpl} {/section} Maciek > -----Original Message----- > From: ivo@uranos.cto.us.edu.pl > [mailto:ivo@uranos.cto.us.edu.pl]On Behalf Of Ivo Jansch > Sent: Tuesday, March 27, 2001 9:50 AM > To: smarty@lists.ispi.net > Subject: [smarty] Re: nested template question > > > Hi, > > Andrei Zmievski wrote: > > > > The problem is: This doesn't work. For it to work, item.tpl should be: > > > <br><a > > > href="{$yourbookmarks/url}">{$yourbookmarks/name}</a> > > It seems that it should be {$outer/url} instead of {$yourbookmarks/url}. > > You index by the section name, not by other variables. > > Ok, but still, that doesn't solve the problem. > > My assigns look like this: > > $smarty->assign("mybookmarks", > array(array("url" => > "http://www.achievo.com", "name" => > "Achievo"), > array("url" => > "http://www.google.com", "name" => > "Google"))); > > $smarty->assign("yourbookmarks", > array(array("url" => > "http://www.ibuildings.nl", "name" => > "Ibuildings"), > array("url" => > "http://www.altavista.com", "name" => > "Altavista"))); > > > *the question* > > How do I create a template that displays mybookmarks AND yourbookmarks, > using only ONE item.tpl that will render both urls. (and without the > assigning of variables to item.tpl in the include statement) > > Ideally, it would look like this, but that doesn't work: > > item.tpl: > <a href="{url}">{name}</a> > > index.tpl: > My bookmarks: > {section name=sec1 loop=$mybookmarks} > {include file="item.tpl} > {/section} > <br><br>Your bookmarks: > {section name=sec2 loop=$yourbookmarks} > {include file="item.tpl} > {/section} > > Maybe the $smarty->assign statements should be changed, but that's no > problem, as long as I can reuse item.tpl. (My problem is actually bigger > and uses large templates, but this is the simplest form in which the > problem occurs) > > Maybe it's possible to change Smarty a bit, so that if I do something > like this: > {include file="item.tpl" pass=true} > it passes all variables to the template, as if it was: > {include file="item.tpl" name=$sec1/mybookmarks.name > url=$sec1/mybookmarks.url} > > Is that doable? > > Greetings, > Ivo > > -- > Ivo Jansch <ivo@ibuildings.nl> > ibuildings.nl BV - information technology > http://www.ibuildings.nl > > --- > You are currently subscribed to smarty as: muhlig@us.edu.pl > 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 (#444) next »