在Cakephp中使用tidy来格式化页面代码
本文主要讨论在Cakephp中使用tidy的函数位置,并不涉及tidy的具体参数,如有需要,请参考我以前的博客。主要是修改appController类的afterFilter方法。具体如下:
class AppController extends Controller {
//.....
function afterFilter() {
if (function_exists("tidy_repair_string")){
$this->output=tidy_repair_string($this->output,array('output-xhtml'=>true),'raw');
}
}
//.....
}
在这里afterFilter ()可以修改一个Cakephp周期内生成的全部内容哦,真是一夫当关万夫莫开。牛。哈哈。
本文来自苏南的博客, 转载请注明网址:http://newsn.net, 谢谢!
我的淘宝小店:http://68zz.com
我的Sina圈子:http://q.blog.sina.com.cn/pctalk
