What is a Zend View Filter? I see them mentioned in the ZF1 documentation, http://framework.zend.com/manual/1.12/en/zend.view.introduction.html, and in the Zend_View
code, but I can't find an explanation for them.
Perhaps it is to support other templating systems which have filters? In that case, what do the filters do in these templating systems?
Thanks!
here is an example of a Zend View Filter:
http://dev.bigace.org/api/3.0/Bigace_Zend/View_Filter/Bigace_Zend_View_Filter_ObfuscateMailto.html
It filters found mailto links and obfuscates them.
A Zend View Filter does something on an already rendered phtml file (= html code) before it is send to the client.
It's a Zend_Filter that can be used on the Zend View output.
Here is another example with code from:
http://www.phpgangsta.de/zend_view-output-filter-whitespaces-aus-html-entfernen
The filter class (filters whitespaces from html = less code to send):
<?php
class App_View_Filter_Minify implements Zend_Filter_Interface
{
public function filter($string)
{
return preg_replace(
array('/>\s+/', '/\s+</', '/[\r\n]+/'),
array('>', '<', ' '),
$string
);
}
}
And then adding the filter to the view:
/**
* Add Output filters to View
*
* @return void
*/
protected function _initViewFilter()
{
$view = $this->getResource('view');
$view->addFilterPath('App/View/Filter', 'App_View_Filter_')
->addFilter('Minify');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With