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

How to call a template from PHP without old variables

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


Joined: 07 Oct 2009
Posts: 13

PostPosted: Thu Oct 08, 2009 4:42 pm    Post subject: How to call a template from PHP without old variables Reply with quote

How can a template be called from PHP and ensured that optional variables are empty?

Is there a way to do something like {include} did (at least in Smarty2) - call a template and delete(suspend) all variables defined earlier?

First, I thought: "thats what the new Smarty_Data objects are good for" - but they solve the problem only in one direction - avoiding local variables being accidentally used somewhere else - but how to go other way round - avoiding earlier defined variables being used in local scope?
Back to top
View user's profile Send private message
eposjk
Smarty Rookie


Joined: 07 Oct 2009
Posts: 13

PostPosted: Fri Oct 09, 2009 9:12 am    Post subject: Reply with quote

I found it out myself - reading the code helps!
Code:
$data = new Smarty_Data( array() );

sets up a variable context which ignores the variables defined before!
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