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

From: Date: Thu, 13 Feb 2003 10:02:11 +0000
Subject: Re: [SMARTY] Assigning from an array in a loop
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7716@lists.php.net to get a copy of this message
In the Country example this worked, but in the latter example for subject goups, that was implemented in a {section} loop it did not. $GROUP_CODES is an array like "03" => "General literature". I a loop {$subjects[id]->SubjectCode} prints 03 but {$GROUP_CODES.$group} prints nothing assigned $group prints just '->SubjectCode' gawan "Jason Sweat" <sweatjejm@mchsi.com> wrote in message news:00f501c2d30c$492f4c60$650aa8c0@sweat.d2g.com... > 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 (#7716) next »