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

{assign var="x" value="val"} is invivsib

 
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
Sanek
Smarty n00b


Joined: 06 Oct 2004
Posts: 2

PostPosted: Wed Oct 06, 2004 2:40 pm    Post subject: {assign var="x" value="val"} is invivsib Reply with quote

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
Code:
String: {$x}


At last we will see:
Code:
String:

Variable value lost!
How can I get variable value in included template?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Oct 06, 2004 3:06 pm    Post subject: Reply with quote

works for me? caching?

an alternate to the {assign} method would be:

{include file="tpl2.tpl" x=$ValValue}
Back to top
View user's profile Send private message Visit poster's website
Sanek
Smarty n00b


Joined: 06 Oct 2004
Posts: 2

PostPosted: Wed Oct 06, 2004 3:14 pm    Post subject: Re: {assign var="x" value="val"} is invi Reply with quote

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:
Code:
String:

Variable value lost!
How can I get variable value in parent (including) template?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Wed Oct 06, 2004 3:19 pm    Post subject: Reply with quote

That is by design, the assigned values from within a template are scoped, only available to itself and descendants.
Back to top
View user's profile Send private message 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