Re: [SMARTY] dumb q (variable assignment from assoc arrays)
| From: | Christopher J. Mackie | Date: | Thu, 08 Jul 2004 20:46:38 +0000 |
| Subject: | Re: [SMARTY] dumb q (variable assignment from assoc arrays) | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11551@lists.php.net to get a copy of this message | ||
Thanks, Monte; As you can see from the code, I'm using exactly the same
names to assign the foreach loop, in the same template--one assignment
works, and the other doesn't. I've appended the actual template and the
code that calls it to the bottom of the msg, hoping that I'm a complete
idiot and have missed something stupid.
Also, here's the debug console output, FYI--again, it looks perfectly OK to
me (I've modified a couple of pieces of data for privacy reasons, but
nothing substantive). I notice that the array index is at the end of the
array--but I've tried putting the {$fieldlist.PreferredName} syntax before
the loop, and that doesn't work either.
If what I'm doing really is supposed to work, could there be some switch or
config in Smarty that might be shutting this option down? This {$array.key}
syntax has never worked on my system (Windows 2003 Server, PHP4.3.6) in
*any* template.
{$SCRIPT_NAME} /usermgr/app_contact_info.php
{$action_url} http://_...
{$app_name} My App
{$is_auth} 1
{$dept_name} MyDept
{$error_msg} empty
{$fieldlist} Array (8)
Salutation => empty
PreferredName => O'Chris
FName => Christopher
MName => empty
LName => Mackie
Phone => 999.999.9999
Fax => 999.999.9999
PostalAddress => empty
{$helpID} app_contact_info
{$host_dept_name} MyHostDept
{$k} PostalAddress
{$ref_page} /....php
{$signpost} EDIT CONTACT INFORMATION
{$v} empty
assigned config file variables (outer template scope):
{#files#} Array (0)
{#vars#} Array (0)
================================== begin Template:
{include file="
$dept_name_header.tpl"}
<!-- TOP - ALL PAGE-SPECIFIC CONTENT GOES BELOW HERE - TOP -->
<h3>Edit Contact Information</h3>
<h4>{$user_fullname}</h4>
<p class=errormsg>{$error_msg}</p>
<table>
<form method=post action="{$action_url}>
<tr><td width="20%"> </td><td
width="80%"> </td></tr>
<tr class=row{cycle values="2,1"}>
<td width="20%">HERE {$fieldlist.Salutation}</td>
<td width="80%">THERE {$fieldlist.Salutation}</td>
</tr>
{foreach name=inner from=$fieldlist item=v key=k}
<tr class=row{cycle values="2,1"}>
<td width="20%">{$k}</td>
<td width="80%"><textarea name={$k}>{$v}</textarea></td>
</tr>
{foreachelse}
<tr>
<td colspan="2">There is no information available</td>
</tr>
{/foreach}
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Save Changes
>>"</td>
</tr>
</form>
</table>
<!-- BOTTOM - ALL CONTENT GOES ABOVE HERE - BOTTOM -->
{include file="$dept_name_footer.tpl"}
========================= end Template
=========================begin calling script
function displayAppContactInfoEditForm( $errormsg = '', $info_ary ) {
$smarty = new Smarty_FacSearch;
$smarty->debugging = true;
$template_root = 'app_contact_info';
$smarty->assign( 'helpID', $template_root );
$smarty->assign( 'signpost', strtoupper(
$smarty->signposts[$template_root] ) );
$smarty->assign( 'action_url', 'http://....php' );
$smarty->assign( 'error_msg', $errormsg );
$smarty->assign( 'fieldlist', $info_ary );
$smarty->display( $template_root . '.tpl' );
}
======================== end calling script
"Monte Ohrt" <monte@ispi.net> wrote in message
news:40EDA83E.6010406@ispi.net...
> 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.