Question about Sections in Sections
| From: | Harald Fielker | Date: | Thu, 23 May 2002 09:32:44 +0000 |
| Subject: | Question about Sections in Sections | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-4379@lists.php.net to get a copy of this message | ||
Hi,
I have a question about nesting section in sections.
I have an array with N elements. Some of this elemtent are arrays containing
M(N) elements. Now i want to run in a section over all N elements and a
nested inner section over M(N) elements.
Here some example code:
// php code
$a = array();
$a[ "x" ] = array( "x", "y", "z" );
$a[ "y" ] = array( "a", "b", "c" );
$a["nest"]["foo"] = array();
$a["nest"]["foo"][] = array( "1", "2", "3" );
$a["nest"]["foo"][] = array( "e","r" );
$a["nest"]["foo"][] = array( );
...
$Smarty->assign( "AX", $a["x"] );
$Smarty->assign( "AY", $a["y"] );
$Smarty->assign( "Anest", $a["nest"] );
Here the template:
{section name=i loop=$AX }
X: {$AX[i]}
Y: {$AY[i]}
{section name=k loop=$Anest["nest"]["foo"][i] } {* here i have parse err*}
foo for i: {$Anest["nest"]["foo"][i][k]}
{/section}
{/section}
I got Smarty engine parse erros in the marked line.
Why can't I use a nested array (with hashes) in a section/loop? Is there a
workaround? Currently i create the inner loop in php and pass just a simple
string to smarty - but I don't like this.
--
Bye,
Harald Fielker
Email: hfielker@softsolutions.de
WWW: www.softsolutions.de