|
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 |
bkw Smarty n00b
Joined: 15 Dec 2003 Posts: 1
|
Posted: Mon Dec 15, 2003 6:13 pm Post subject: accessing smarty object in modifiers |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Dec 15, 2003 7:06 pm Post subject: |
|
|
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 |
|
limpidnova Smarty Rookie
Joined: 13 Jun 2005 Posts: 11
|
Posted: Mon Jun 13, 2005 5:06 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 13, 2005 5:30 pm Post subject: |
|
|
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 Some may make Smarty a property of an object, or create it within a function/method. |
|
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
|