[SMARTY] Unregistering output filter method (and solution)

Marcus Bointon <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
One for the archives.

I register an output filter using a method within a smarty subclass  
like this:

$this->register_outputfilter(array($this, 'myoutputfilter'));

Now I wantHow should I unregister a filter that's declared that way  
from outside the instance? I initially tried:

$smarty->unregister_outputfilter(array($smarty, 'myoutputfilter'));

(where $smarty is the same instance as $this) but that doesn't work  
(it keeps on filtering).

I noticed that the object reference syntax is not shown in the docs  
for unregister_outputfilter(), so I though I'd just give it a try  
without the object reference syntax within a new method, and it works!

public function disablefilter() {
     $this->unregister_outputfilter('myoutputfilter');
}

It would be nice to have this mentioned on the docs for  
unregister_outputfilter.

I guess that this may potentially have implications if you also have  
global output filters with the same names that you don't want to  
unregister, but then if you code like that you deserve it!

Incidentally I think that the bug that was killing my template output  
was in this output filter method, as I'm now getting expected output.

Marcus
-- 
Marcus Bointon
[email protected] | http://www.bointon.com/

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.