[英]Load phtml content in custom viewhelper?
在我的主要layout.phtml文件中,我包含了一個自定義的viewhelper。 viewhelper具有大量靜態html內容,並將其返回到布局。
有沒有一種方法可以使viewhelper從外部phtml文件加載此html內容?
抽象示例:
Layout:
<?php echo $this->viewHelperGiveMeHtml(); ?> //<div>Foobar</div>
ViewHelper:
class Zend_View_Helper_ViewHelperGiveMeHtml extends Zend_View_Helper_Abstract{
public function viewHelperGiveMeHtml(){
return retrieveHtmlFromPhtml('foobar.phtml'); //how can i load an phtml? file
}
}
foobar.phtml:
<div>Foobar</div>
public function viewHelperGiveMeHtml(){
$this->view->render('foobar.phtml');
}
簡要說明:
調用視圖助手時, $this->viewHelperGiveMeHtml();
在內部視圖中, Zend_View
初始化給定的幫助器類,並使用Zend_View_Helper_Abstract::setView
方法傳遞自身。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.