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

 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
kofi_kari_kari
Smarty n00b


Joined: 06 Feb 2012
Posts: 2

PostPosted: Mon Feb 06, 2012 5:40 am    Post subject: Changing variable between template Reply with quote

Hi there!

I'm currently working on a smarty template "tree". I have a parent template that have children and grand children.
I created variables at the parent level and I can use them in the children and grand children template. However, when I change the value of the variables in the children or grand children template, the value doesn't change at the parent level.

Is there a mean of doing so? I would like to be able to change, in a children template, the value of a variable, created in a parent level, and to be able to use this changed value in the parent level.

I tried everything:
{assign var="foo" value="whatever" scope="global"}
{assign var="foo" value="whatever" scope="root"}

But it doesn't seem to work

Many thanks for your help.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Feb 06, 2012 7:29 pm    Post subject: Reply with quote

Do you use template inheritance, as you talk about parent and child templates?

Note that at template inheritace in the child templates everything outside {block}...{/block} tags is ignored.
Back to top
View user's profile Send private message
kofi_kari_kari
Smarty n00b


Joined: 06 Feb 2012
Posts: 2

PostPosted: Tue Feb 07, 2012 9:53 pm    Post subject: Reply with quote

Thank you. I tried to use this features but it doesn't seem to solve my problem. I change the way I'm doing it. I use the variable in the php program and it work fine in smarty now.

Thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks 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