Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Smarty cannot call filters that are static members

 
Post new topic   Reply to topic    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
johndoe1395
Smarty n00b


Joined: 13 Apr 2013
Posts: 2

PostPosted: Sat Apr 13, 2013 9:22 pm    Post subject: Smarty cannot call filters that are static members Reply with quote

Hello everyone

I registered an output filter with
$this->registerFilter("output", "ClassName::functionName");
and although this works with blocks and custom functions it throws a "call to undefined function" error when used with filters.

A quick fix would be replacing line 60 with
$output = call_user_func($template->smarty->registered_filters[$type][$key], $output, $template);
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Apr 14, 2013 6:20 am    Post subject: Reply with quote

The valid PHP callback for a statict class is an array of class and method name.

Code:
$this->registerFilter("output", array("ClassName","functionName"));
Back to top
View user's profile Send private message
johndoe1395
Smarty n00b


Joined: 13 Apr 2013
Posts: 2

PostPosted: Mon Apr 15, 2013 8:28 pm    Post subject: Reply with quote

Nice, thanks! Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Bugs 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