Re: [SMARTY] Assigning from an array in a loop

From: Date: Thu, 13 Feb 2003 03:02:00 +0000
Subject: Re: [SMARTY] Assigning from an array in a loop
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7710@lists.php.net to get a copy of this message
assuming $ISO_COUNTRIES is a bunch of code=>names, and, as you stated, {$ISO_COUNTRIES.$country} prints the name, then {$country} should print the code "gawan" <mail@gawan.net> wrote in message news:20030213011149.76013.qmail@pb1.pair.com... > 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

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