| Christopher J. Mackie 2004-07-08, 4:04 pm |
| 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
|