|
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 |
appel Smarty Rookie
Joined: 27 May 2003 Posts: 29
|
Posted: Fri Jun 20, 2003 7:05 pm Post subject: Registering a pre_filter that is a member function?? |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Fri Jun 20, 2003 8:21 pm Post subject: |
|
|
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 |
|
|
|
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
|