|
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 |
Sanek Smarty n00b
Joined: 06 Oct 2004 Posts: 2
|
Posted: Wed Oct 06, 2004 2:40 pm Post subject: {assign var="x" value="val"} is invivsib |
|
|
index.php:
Code: | ...
$smarty->assign("ValValue", "Print this string");
$smarty->display("tpl1.tpl");
|
Template: tpl1.tpl
Code: | {assign var="x" value="$ValValue"}
{include file="tpl2.tpl"}
|
Template: tpl2.tpl
At last we will see:
Variable value lost!
How can I get variable value in included template? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Oct 06, 2004 3:06 pm Post subject: |
|
|
works for me? caching?
an alternate to the {assign} method would be:
{include file="tpl2.tpl" x=$ValValue} |
|
Back to top |
|
Sanek Smarty n00b
Joined: 06 Oct 2004 Posts: 2
|
Posted: Wed Oct 06, 2004 3:14 pm Post subject: Re: {assign var="x" value="val"} is invi |
|
|
Sorry, I mean:
index.php:
Code: | ...
$smarty->assign("ValValue", "Print this string");
$smarty->display("tpl1.tpl");
|
Template: tpl1.tpl
Code: | {include file="tpl2.tpl"}
String: {$x}
|
Template: tpl2.tpl
Code: | {assign var="x" value="$ValValue"}
|
At last we will see:
Variable value lost!
How can I get variable value in parent (including) template? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Oct 06, 2004 3:19 pm Post subject: |
|
|
That is by design, the assigned values from within a template are scoped, only available to itself and descendants. |
|
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
|