Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

vars not passed via include file in foreach

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
ezmil
Smarty Rookie


Joined: 06 Feb 2010
Posts: 6

PostPosted: Tue Apr 27, 2010 11:31 am    Post subject: vars not passed via include file in foreach Reply with quote

hi,

I have a foreach containing an include file. Some dynamic vars should be passed to the included template. Doesn't seem to work ...

Code:

{foreach $array as $value}
   This is a Test: {$value.id}
   <br/>
   {include file="template.tpl" id=$value.id}
{/foreach}


In included template I try to grab {$id} and it has always the value of the last foreach iteration.

Code:

This is the id to be shown in template.tpl: {$id}. If $array.id has values 1,2,3 $id is always 3.


The test-loop outside the include file is always correct.

Any ideas?

Thx, mil
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5067
Location: Hamburg / Germany

PostPosted: Tue Apr 27, 2010 5:44 pm    Post subject: Reply with quote

I can't reproduce the problem.

You said:
If $array.id has values 1,2,3 $id is always 3.

I think you did mean $value.id, correct?

Did you use caching?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 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