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

Modifier calling other modifiers

 
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 -> General
View previous topic :: View next topic  
Author Message
eadz
Smarty Regular


Joined: 30 Apr 2003
Posts: 61
Location: Auckland, New Zealand

PostPosted: Wed May 21, 2003 12:02 pm    Post subject: Modifier calling other modifiers Reply with quote

Hi there,
I want to make a modifier plugin, that calls other plugins based on settings in a database.

I.e. {$myvar|dbmodify} and it would look up the database, and then depending on the setting in the database, apply nl2br and other modifiers.

How would I call another modifier from within a modifier plugin?
_________________
bBlog - Smarty based blogging software
I work for Webforce web site design ( Auckland, NZ )
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


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

PostPosted: Wed May 21, 2003 5:37 pm    Post subject: Reply with quote

In your new modifier, plugin, whatever...

eg:

require_once $smarty->_get_plugin_filepath('modifier', 'capitalize');

then call the modifier's function directly:

$output = smarty_modifier_capitalize( $input );

Rinse, Repeat.
Back to top
View user's profile Send private message
eadz
Smarty Regular


Joined: 30 Apr 2003
Posts: 61
Location: Auckland, New Zealand

PostPosted: Thu May 22, 2003 12:04 am    Post subject: Reply with quote

Thankyou very much!
_________________
bBlog - Smarty based blogging software
I work for Webforce web site design ( Auckland, NZ )
Back to top
View user's profile Send private message Visit poster's website
ubaldo
Smarty Regular


Joined: 21 Apr 2003
Posts: 35
Location: Barcelona, Spain

PostPosted: Mon Jun 09, 2003 9:37 am    Post subject: Yes, but another instance of smarty? Reply with quote

Unlike smarty functions, modifier functions don't get a smarty pointer reference, so, another smarty instance has to be created. In my case, the smarty instance isn't very cheap, because i do some extra initialization (I subclass Smarty)

I guess that there is no other way around. My question is, why do I get a smarty pointer in custom functions and not in custom modifiers?
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


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

PostPosted: Mon Jun 09, 2003 10:11 am    Post subject: Reply with quote

Hi ubaldo. It sounds like you would be interested in this topic concerning $this in modifiers.

I think it would be nice if all api functions received $this Smile
Back to top
View user's profile Send private message
ubaldo
Smarty Regular


Joined: 21 Apr 2003
Posts: 35
Location: Barcelona, Spain

PostPosted: Mon Jun 09, 2003 10:47 am    Post subject: Reply with quote

Thanks for the heads up

I already replied to the subject

http://www.phpinsider.com/smarty-forum/viewtopic.php?p=2365#2365

and casted my vote?

Do you know if the proposed 'object method as modifier function' is implemented in 2.5?
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 -> General 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