Re: [SMARTY] dumb q (variable assignment from assoc arrays)
| From: | Monte Ohrt | Date: | Thu, 08 Jul 2004 20:02:06 +0000 |
| Subject: | Re: [SMARTY] dumb q (variable assignment from assoc arrays) | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11550@lists.php.net to get a copy of this message | ||
You might double check where you use "fieldlist" and "field_list", or make them the same to avoid errors. Also check the debug console output.
Christopher J. Mackie wrote:
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: ChristopherPrefname: 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