Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
accessing smarty object in modifiers

 
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
bkw
Smarty n00b


Joined: 15 Dec 2003
Posts: 1

PostPosted: Mon Dec 15, 2003 6:13 pm    Post subject: accessing smarty object in modifiers Reply with quote

I'm looking for a way to make the behaviour of modifiers depend on properties of the smarty object. Since modifiers are not Smarty-methods, and are not handed the object, I wonder how this could be done.

The primary reason for wanting to do this is the following:

I'd like to set a default characterset for smarty, which is the used in modifier.escape as the third argument to htmlentities. This is needed for displaying the Euro-Symbol in ISO-8859-15.

Any Idea?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5613
Location: Toronto, Canada

PostPosted: Mon Dec 15, 2003 7:06 pm    Post subject: Reply with quote

I suggested this quite awhile ago and I still think it would be a nice addition: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=185. There is some followup material in there for you.

There are workarounds: the most promising is the one that messju told me: put your modifier function in a class that holds an instance of your smarty object then register your modifier using the API. That way, the modifier can access smarty from the local class reference.
Back to top
View user's profile Send private message
limpidnova
Smarty Rookie


Joined: 13 Jun 2005
Posts: 11

PostPosted: Mon Jun 13, 2005 5:06 pm    Post subject: Reply with quote

i know this is an old post; but since i needed this to work, and found a solution figured i'd post it

the simplest method is just to call the global object you defined smraty as;
in my case it's defined as $template; so if i use "global $template" it brough in the object perfectly...
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Mon Jun 13, 2005 5:30 pm    Post subject: Reply with quote

limpidnova wrote:
i know this is an old post; but since i needed this to work, and found a solution figured i'd post it

the simplest method is just to call the global object you defined smraty as;
in my case it's defined as $template; so if i use "global $template" it brough in the object perfectly...


That is assuming your smarty object was instantiated globally Wink Some may make Smarty a property of an object, or create it within a function/method.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests 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