referencing associative arrays using template variables
| From: | Jason Sweat | Date: | Wed, 27 Jun 2001 02:30:53 +0000 |
| Subject: | referencing associative arrays using template variables | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1013@lists.php.net to get a copy of this message | ||
I would like to use Smarty to reference the associative array that is the loop variable of an outer
section using the data from the current value of a loop variable of an inner section. My template
looks like this:
<?xml version="1.0" ?>
<{$BASETAG}>
{section name=data loop=$DATA}
<{$DETAILTAG} id="{%data.index%}">
{section name=xml loop=$XML}
<{$XML[xml]}>{$DATA[data].$XML[xml]}</{$XML[xml]}>
{/section}
</{$DETAILTAG}>
{/section}
</{$BASETAG}>
Smarty does not like the {$DATA[data].$XML[xml]} syntax and gives the following error:syntax error:
unknown tag - '$DATA[data].{$XML[%xml.index%]' in
<b>/usr/local/lib/php4/Smarty_Compiler.class.php</b> on line <b>862</b>
I think I could work around this by restructuring the $DATA array to have a second dimension that
reorders the associative array to be in the same order as the $XML array in my php script before
assigning the arrays to Smarty, but I would rather dynamically reference the $DATA array using the
$XML array if possible.
TIA
Jason