Re: loop
| From: | Ivo Jansch | Date: | Thu, 29 Mar 2001 07:26:56 +0000 |
| Subject: | Re: loop | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-491@lists.php.net to get a copy of this message | ||
Hi,
Andrei Zmievski wrote:
> > - Change the syntax a bit, perhaps {$sec1/@items.url} or something like
> > that..
> Coming up with good syntax is where the crux of the problem is.
Well, what about this @?
if you do this:
assign("items",array("foo","bar")), then
$sec1/@items inside a section would display "foo"
if instead you do this:
assign("items",array(array("name"=>"foo","url"=>"bar"))),
then
$sec1/@items.name inside a section would display "foo"
if instead you do this:
assign("items",array("name"=>array("foo","bar"))), then
$sec1/items.@name would display "foo"
if finally you do this:
assign("items",array("name"=>array(array("first"=>"foo","last"=>"bar")))),
then
$sec1/items.@name.first would display "foo"
Wouldn't that be sufficient?
I think a problem could arise with nested sections. That would look
like:
assign("books",array(array("title"=>"smarty for dummies",
"authors"=>array("monte","andrei")));
{section name=outer loop=$books}
Title: {outer/@books.title}
Written by:
<ul>
{section name=inner loop=@books.authors}
<li>{$outer/inner/@books.@authors} -> possible ambiguity..
{/section}
</ul>
{/section}
Maybe that should be {$outer.@books/inner.@authors} or something..
at least something that the compiler can convert to:
$books[$_sections['outer']['properties']['index']]['authors'][$_sections['inner']['properties']['index']];
Greetings,
Ivo
--
Ivo Jansch <ivo@ibuildings.nl>
ibuildings.nl BV - information technology
http://www.ibuildings.nl