Variable bleed??
| From: | Gerard Samuel | Date: | Tue, 10 Dec 2002 21:30:02 +0000 |
| Subject: | Variable bleed?? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-6716@lists.php.net to get a copy of this message | ||
I just ran into a scenario, and Im not sure how its happening.
I have a page that displays "blocks" along with center content.
One block on the left is a poll. In the poll block's php code Im using an array $data. One template variable comes from the php $data array ->
$smarty->assign('poll_option', $data['options']);
In all my scripts I make it a habit to assign, display, then clear template variables.
Now on this one page, the center content is getting a template array "data".
$smarty->assign('data', $file);
Im using {foreach} to loop throught the template array like so ->
{foreach item=line from=$data}
{$line}
{/foreach}
For some reason, the template loop is displaying the last row of the array $data from the poll block.
The quick and easy could be to rename the center content template variable. But what is the general consensus about variable naming
for templates? Is it possible for php variables, and template variables to clash? What is additionally confusing is that both the poll block and
center content are in functions. Those variables should only exist in their particular functions.
Ill keep looking, but if anyone has run into something like this, Ill be glad to hear what you have to say...
Thanks for listening...
--
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/