|
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 |
ilyalyu Smarty Regular
Joined: 03 Nov 2009 Posts: 72
|
Posted: Thu Jan 26, 2012 12:57 pm Post subject: Smarty property is invisible in subtemplate |
|
|
Parent template: Code: | {foreach $array as $x}{include 'subtemplate'}{/foreach} |
Child template:
Child template outputs nothing. I think that, as long as $x is visible in subtemplate, $x@index also should be visible in subtemplate.
Strangely, if {$x@index} is used in parent template, it becomes visible in subtemplate too. Parent template: Code: | {foreach $array as $x}{$x@index}{include 'subtemplate'}{/foreach} |
Child template: |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Jan 26, 2012 4:09 pm Post subject: |
|
|
With {foreach} you could use a lot of different properties.
For speed optimization Smarty does just calculate and fill properties which are used in the template.
But Smarty does not know if you will use propeties in subtemplates.
The only workaround is to mkae the property used in the main template
Code: | {foreach $array as $x}{$foo=$x@index}{include 'subtemplate'}{/foreach} |
|
|
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
|