Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

foreach - doubled $this->_tpl_vars['$this->_tp

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
amorek
Smarty n00b


Joined: 17 Apr 2004
Posts: 4

PostPosted: Sat Apr 17, 2004 9:56 pm    Post subject: foreach - doubled $this->_tpl_vars['$this->_tp Reply with quote

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
View user's profile Send private message
amorek
Smarty n00b


Joined: 17 Apr 2004
Posts: 4

PostPosted: Sat Apr 17, 2004 10:08 pm    Post subject: Reply with quote

I corrected that problem in the smarty.compile file.
Line 1164:
was: foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"
now is: foreach (\$_from as $key_part$item):\n

The same problem in line 1158

Should you correct that in future?

best regards
amor


Last edited by amorek on Wed May 05, 2010 10:49 pm; edited 1 time in total
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Apr 17, 2004 11:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Apr 18, 2004 6:12 am    Post subject: Re: foreach - doubled $this->_tpl_vars['$this->_tpl_va Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP