Assigning from an array in a loop
| From: | gawan | Date: | Thu, 13 Feb 2003 01:18:25 +0000 |
| Subject: | Assigning from an array in a loop | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-7706@lists.php.net to get a copy of this message | ||
Hi
I learned from this group to use the following construct
to assign a natural language substitute for a code fetched
from a database:
{if $product->CountryOfPublication}
{assign var="country" value="$product->CountryOfPublication"}
<font color="#666666"><b>Country:
</b></font>{$ISO_COUNTRIES.$country}<br>
{/if}
This gives me a country name instead of the country code.
But when tried the same thing inside a section loop, this method failes:
{section name=id loop=$subjects}
<!-- some other tests here -->
{if $subjects[id]->SubjectSchemeName eq 'TR'}
{assign var="group" value="$subjects[id]->SubjectCode"}
Product group: {$subjects[id]->SubjectCode} {$GROUP_CODES.$group}<br>
{/if}
{/section}
This gives me the code {$subjects[id]->SubjectCode} but not the
descriptive name for the code, {$GROUP_CODES.$group,}
as I would expect from the first example.
I did doublecheck the presence of the GROUP_CODES array, that seems not
to be a problem. {$group} displays this: '->SubjectCode'
Any advise?
TIA