Zend Framework 3, как можно вызвать phtml файл в контроллере - PullRequest
0 голосов
/ 23 февраля 2019

Я хочу получить HTML-контент в контроллере.для этого

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

}

Может кто-нибудь помочь для получения содержимого html в контроллере.Спасибо

1 Ответ

0 голосов
/ 26 февраля 2019

Попробуйте это:

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;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...