Re: [SMARTY] Question about Sections in Sections

From: Date: Thu, 23 May 2002 09:49:28 +0000
Subject: Re: [SMARTY] Question about Sections in Sections
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-4380@lists.php.net to get a copy of this message
Try: {section name=i loop=$AX } X: {$AX[i]} Y: {$AY[i]} {section name=k loop=$Anest.nest.foo[i] } foo for i: {$Anest.nest.foo[i][k]} {/section} {/section} Might use the standard smarty syntax for accessing associative arrays. -bok On 23/5/02 7:32 PM, Harald Fielker banged a keyboard and produced the following weird but readable email: > 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. >

« previous php.smarty.general (#4380) next »