Re: loop
| From: | Ivo Jansch | Date: | Wed, 28 Mar 2001 08:47:34 +0000 |
| Subject: | Re: loop | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-467@lists.php.net to get a copy of this message | ||
Hi,
Andrei Zmievski wrote:
> I'm aware of the problem - just haven't come up with a good way to solve
> it..
Ok, I played a little with Smarty_Compiler.class.php, and in _parse_var,
I put the foreach($props) loop *in front* of the $foreach($sections)
loop.
Now all my datastructures work.
Even a complex datastructure like:
$smarty->assign("bookmarks",
array(
array(
"url" => "http://www.achievo.com",
"name" => Array(
"items"=>Array(
"oeli",
"1111",
"boeli"
)
)
),
array(
"url" => "http://www.google.com",
"name" => Array(
"items"=>Array(
"first",
"oeli",
"boeli",
"ddddd"
)
)
)
)
);
Is there an existing situation which would be broken by the change I
made? Otherwise this might be a useful fix to Smarty for other people
too.
I also added a line to _compile_include_tag:
" extract(\$include_vars);\n" .
" extract(\$include_vars['default']);\n" . // ivo hack
" include \"\$file_name.php\";\n" .
I did this to cope with the previously discussed nested templates
problem.
With this hack, I'm able to do the following:
{section name=mysection loop=$yourbookmarks}
{include file="item.tpl" default=$mysection/yourbookmarks}
{/section}
and then have an item.tpl which uses {$url} instead of {$default.url}.
(makes life easier for the template editor).
(The templates used to render the above datastructure look quite simple
thanks to these changes. If anyone would like to see them, I could post
them too)
Greetings,
Ivo
--
Ivo Jansch <ivo@ibuildings.nl>
ibuildings.nl BV - information technology
http://www.ibuildings.nl