dumb q (variable assignment from assoc arrays)

From: Date: Thu, 08 Jul 2004 19:40:50 +0000
Subject: dumb q (variable assignment from assoc arrays)
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11549@lists.php.net to get a copy of this message
I've got a template where the following works perfectly $fieldlist=array ( 'LName' => 'Mackie', 'FName' => 'Christopher', 'PrefName' => 'CJ'); $smarty->assign( 'field_list', $fieldlist ); ----- in fieldlist.tpl {foreach from=$field_list item=v key=k} <tr> <td>{$k}: </t> <td>{$v}</t> </tr> {/foreach} --------- output --------- LName: Mackie FName: Christopher Prefname: CJ -------------------------- Reading the manual ("assigning vars from associative arrays"), it seems to me that this should also work {$field_list.PrefName} {$field_list.FName} {$field_list.LName} ------- to produce CJ Christopher Mackie But I can't get that second syntax to work at all--not using 'dot' syntax, not using [0] syntax, and certainly not using object syntax. The object syntax is the only one that actually throws an error; the others just return nothing. The manuals make it look easy: my templates make it seem impossible. Can anyone tell me what I'm missing? I'm sure it's something incredibly dumb--but I've read that man page 50x, and I can't see it. Tx, --CJ

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