|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
amorek Smarty n00b
Joined: 17 Apr 2004 Posts: 4
|
Posted: Sat Apr 17, 2004 9:56 pm Post subject: foreach - doubled $this->_tpl_vars['$this->_tp |
|
|
Hi.
I get this error:
Parse error: parse error, unexpected T_STRING, expecting ']' in f:\usr\www\smarty_dirs\pokeronline\templates_c\%%-41^%%-416848289^_layout.htm.php on line 76
Template:
Code: | {foreach from=$db_results_top_list item=$db_row}
{$db_row->name}
{/foreach} |
Compiled tempalte:
Code: | <?php if (count($_from = (array)$this->_tpl_vars['db_results_top_list'])):
foreach ($_from as $this->_tpl_vars['$this->_tpl_vars['db_row']']):
?>
<php echo $this->_tpl_vars['db_row']->name; ?>
<?php endforeach; unset($_from); endif; ?> |
I see that the problem is:
Code: | foreach ($_from as $this->_tpl_vars['$this->_tpl_vars['db_row']']): |
should be:
Code: | foreach ($_from as $this->_tpl_vars['db_row']): |
How to correct that ???
amor
Last edited by amorek on Wed May 05, 2010 10:49 pm; edited 1 time in total |
|
Back to top |
|
amorek Smarty n00b
Joined: 17 Apr 2004 Posts: 4
|
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Apr 17, 2004 11:01 pm Post subject: |
|
|
When accessing an array by key, the correct way to do it is using dot-notation:
{$db_row.name}
Is that what you were after? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sun Apr 18, 2004 6:12 am Post subject: Re: foreach - doubled $this->_tpl_vars['$this->_tpl_va |
|
|
amorek wrote: |
Code: | {foreach from=$db_results_top_list item=$db_row} |
|
that should read Code: | {foreach from=$db_results_top_list item=db_row} |
item has to be a variablename, not a variablevalue |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|