脚本宝典收集整理的这篇文章主要介绍了zend-framework – Zend捕获布局并将内容视为变量,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
public function exempleAction(){ // Using layout "mail" $this->_helPEr->layout()->setLayout("mail"); }
我希望使用以下内容获取视图的HTML内容:(稍后将其用作电子邮件内容)
$view_helper = new Zend_View_Helper_Action(); $html_content = $view_helper->action('exemple','Mycontroller','mymodule');
实际上,布局是在Zend_Layout_Controller_Plugin_Layout的插件的postDisatch()中调用的.
你仍然可以试试这个:
在你的布局’mail.phtml’中把这个:
echo $this->layout()->content;
在你的方法中:
$view_helper = new Zend_View_Helper_Action(); $html_content = $view_helper->action('exemple','mymodule'); $layout_path = $this->_helper->layout()->getLayoutPath(); $layout_mail = new Zend_Layout(); $layout_mail->setLayoutPath($layout_path) // assuming your layouts are in the same directory,otherwise change the path ->setLayout('mail'); // Filling layout $layout_mail->content = $html_content; // Recovery rendering your layout $mail_content = $layout_mail->render(); var_dump($mail_content);
以上是脚本宝典为你收集整理的zend-framework – Zend捕获布局并将内容视为变量全部内容,希望文章能够帮你解决zend-framework – Zend捕获布局并将内容视为变量所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。