zend框架3如何在控制器中调用phtml文件

问题描述 投票:0回答:1

我想在控制器中获取html内容。为了这

public function posteemailAction(){
  $view=$this->render("auth-acl/email/_getemail.phtml");
   print_r($view);die;

}

任何人都可以帮助获取控制器中的HTML内容。谢谢

zend-framework
1个回答
0
投票

试试这个:

public function ajaxAction() {
        // Turns off the layout and the view
        $this->_helper->layout()->disableLayout(); 
        $this->_helper->viewRenderer->setNoRender(true);

        // Creates a new instance of Zend_View
        $html = new Zend_View();

        // Set a script path for above view
        $html->setScriptPath(APPLICATION_PATH . '/views/scripts/your_custom_path/');

        // Assinging some data to the view
        $html->assign('myVar', $someValue);

        // Renders the view to specified variable
        $responseContent = $html->render('mycontent.phtml');

        echo $responseContent;
}
© www.soinside.com 2019 - 2024. All rights reserved.