Smarty 模板引擎和 Gzip 编码
我对 smarty、Zend 和 gzip 编码有一点问题,我扩展了 smarty 类
//This method i call in one front controller plugin
$this->getResponse()->setHeader('Content-Encoding' , 'gzip');
View extends Zend_View_Abstract implements Zend_View_Interface {
public $_smarty;
public function __construct(){
$this->_smarty = new Smarty();
//Hire i have some smarty options paths and etc.
//------------------
//I register this object to smarty template
$this->_smarty->registerObject('Smarty', $this);
//You can see this pulugin at this address
//http://smarty.incutio.com/?page=GZipPlugin
$this->_smarty->loadFilter('output', 'gzip');
}
public function Fetch($tpl){
retutn $this->_smarty->fetch($tpl);
}
//Zend call this method after loaded controller and display active controller tpl
public function Render($tpl){
retutn $this->_smarty->display($tpl);
}
public function Header($params, &$smarty){
$this->_smarty->display('header.tpl');
}
}
好吧... 在我的 index.tpl 中,我调用函数 {Site->header} 我的浏览器 chrome 抛出错误:
Server error.
The website encountered an error while retrieving http://site.dev. It may be down for maintenance or configured incorrectly.
我尝试使用 fetch 加载:
echo $this->_smarty->fetch('header.tpl');
但当我删除输出填充程序站点正在运行时,我遇到了相同的错误。
如果有人可以帮助我,我将不胜感激。 抱歉,如果我的英语不是很好。 提前致谢。
I've a bit problem with smarty, Zend and gzip encoding, I extends the smarty class
//This method i call in one front controller plugin
$this->getResponse()->setHeader('Content-Encoding' , 'gzip');
View extends Zend_View_Abstract implements Zend_View_Interface {
public $_smarty;
public function __construct(){
$this->_smarty = new Smarty();
//Hire i have some smarty options paths and etc.
//------------------
//I register this object to smarty template
$this->_smarty->registerObject('Smarty', $this);
//You can see this pulugin at this address
//http://smarty.incutio.com/?page=GZipPlugin
$this->_smarty->loadFilter('output', 'gzip');
}
public function Fetch($tpl){
retutn $this->_smarty->fetch($tpl);
}
//Zend call this method after loaded controller and display active controller tpl
public function Render($tpl){
retutn $this->_smarty->display($tpl);
}
public function Header($params, &$smarty){
$this->_smarty->display('header.tpl');
}
}
Ok...
in my index.tpl i call the function {Site->header}
and my browser chrome throw the error:
Server error.
The website encountered an error while retrieving http://site.dev. It may be down for maintenance or configured incorrectly.
i've tried to load with fetch like:
echo $this->_smarty->fetch('header.tpl');
but i have the same error, when i remove the out put fillter site is running.
If anyone can help me I would been greatly appreciate it.
Sorry if my english is not very good.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我同意 mfonda 的观点,不要使用 Smarty。
我在需要时使用此插件类来压缩我的整个身体响应:
请注意使用
dispatchLoopShutdown
因为 这篇文章。该类改编自 this我使用 Google 发现的帖子
I agree with mfonda, don't use Smarty.
I use use this plugin class to Gzip my entire body response when needed:
Note the use of
dispatchLoopShutdown
because of this post.The class was adapted from this post I found by using Google