Re: [SMARTY] Section question
| From: | GunIP | Date: | Fri, 17 Oct 2003 04:27:32 +0000 |
| Subject: | Re: [SMARTY] Section question | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10366@lists.php.net to get a copy of this message | ||
try smarty code with this one :
{section name=j loop=$Merchandise.attributes}
<SELECT NAME = "AttributeValue[{$smarty.section.j.index}]">
{section name=x loop=$Merchandise.attributes.value[j]}
<OPTION VALUE = "{$Merchandise.attributes.value[j][x]}"> {$Merchandise.attributes.value[j][x]}
</OPTION>
{/section}
</SELECT>
{/section}
Hi all,
I am having a problem with some {section} code - I've obviously done
something wrong, because it seems like the section iterator does not
reset.
Here is the array getting assigned from the php code:
$smarty->assign('Merchandise',array('links' =>
array($gallery_dir.'photos/merchandise/redshirt.front.jpg',
$gallery_dir.'photos/merchandise/redshirt.back.jpg',
),
'thumbs' =>
array($gallery_dir.'photos/merchandise/thumbs/redshirt.front.thumb.jpg',
$gallery_dir.'photos/merchandise/thumbs/redshirt.back.thumb.jpg',
'price' => ('$20.00'),
'description' => ('Short sleeve t-shirt comes in red and black. Sizes M
- XXL'),
'category_code' => ('S'),
'product_code' => ('SST'),
'has_attributes' => ('true'),
'attr_count' => (2),
'attributes' => array('name' => array('Choose Color', 'Choose Size'),
'value' => array( array('black', 'red'),
array('m', 'l', 'xl', 'xxl'),
)),
));
And here is my Smarty code:
{if $Merchandise.has_attributes == "true"}
{section name=i loop=$Merchandise.attributes.name}
<INPUT TYPE = "hidden" NAME = "AttributeCode[{$smarty.section.i.index}]"
VALUE = "{$Merchandise.attributes.name[i]}">
{/section}
{section name=j loop=$Merchandise.attributes.name}
<SELECT NAME = "AttributeValue[{$smarty.section.j.index}]">
{section name=x loop=$Merchandise.attributes.value}
<OPTION VALUE = "{$Merchandise.attributes.value[j][x]}">
{$Merchandise.attributes.value[j][x]}</OPTION>
{/section}
</SELECT>
{/section}
{/if}
Most of this seems to work. However, when the nested sections run
through, I end up with the first combo box containing "black" and "red"
as expected, but in the second combo box, I only get "m" and "l",
instead of all four values.
How can I write this code to get what I need?
-Erich-
--
#!/gun.ip/