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

Registering a pre_filter that is a member function??

 
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
appel
Smarty Rookie


Joined: 27 May 2003
Posts: 29

PostPosted: Fri Jun 20, 2003 7:05 pm    Post subject: Registering a pre_filter that is a member function?? Reply with quote

How do I register a pre_filter using this technique:

Code:
<?

class SystemTemplate extends Smarty {

   function SystemTemplate() {
      $this->debugging = false;
      $this->security = false;
      $this->caching = false;
      $this->php_handling = SMARTY_PHP_PASSTHRU;
      $this->register_prefilter($this->preFilter);
   }

   function preFilter($tpl_source) {
 ... do something with $tpl_source and return ...
   }

}

?>


I need to use $this->preFilter() as the prefilter function. But how do I do that??
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Jun 20, 2003 8:21 pm    Post subject: Reply with quote

hmm, the current cvs-version of smarty supports object-methods as callbacks for plugins, including pre-filters. you can simply do:
$smarty->register_prefilter(array(&$obj, 'preFilter')).

but cvs is quite unstable at the moment and i don't know when the next stable release (which will almost definately support the stuff above) will be.

so if you don't want to use unstable code, you have to write a wrapper function:

Code:
function filter($tplSource, &$smarty) {
    global $obj;
    return $obj->preFilter($tplSource, $smarty);
}


and register that as a filter.

HTH
messju
Back to top
View user's profile Send private message Send e-mail 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