Re: nested template question
| From: | Ivo Jansch | Date: | Tue, 27 Mar 2001 07:50:25 +0000 |
| Subject: | Re: nested template question | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-443@lists.php.net to get a copy of this message | ||
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