小编Nar*_*jis的帖子

视图渲染在zend中没有按预期正常工作

我的zend布局和脚本检测正常.但是在我的IndexController的init函数中,我写了$ this-> view-> render("header.phtml")它没有显示屏幕上的任何内容,而当我写回信时($ this-> view-> render(" header.phtml");它显示我的header.phtml文件.这是我的IndexController

class IndexController扩展Zend_Controller_Action {

public function init()
{
    $layout = $this->_helper->layout();
    //$this->view = $this->getResource('View');
    echo ($this->view->render("header.phtml"));
        //echo"<pre>";
        //var_dump($this->view);
        //var_dump(APPICATION_PATH);
}

public function indexAction()
{
    // action body
    echo "In default index con";
}
Run Code Online (Sandbox Code Playgroud)

}

另外,当Igive我的url到/ mypath/index它没有显示简单的行"我在索引控制器中",我只是回应.在我的引导程序中,这是我的Zend_Layout设置.

        Zend_Loader::loadClass('Zend_View');
$this->view = new Zend_View();
$this->view->setEncoding('UTF-8');
$this->view->setScriptPath($this->root .'/application/default/views/scripts');
    $viewRenderer=new Zend_Controller_Action_Helper_ViewRenderer();
     // Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
     // $view->setScriptPath($this->root.'/'.$theme.'/views/scripts/');
     //$view->setScriptPath($this->root.'/application/default/views/scripts/');
     $this->view->addScriptPath($this->root.'/application/admin/views/scripts');
     $this->view->addScriptPath($this->root.'/application/business/views/scripts');
    // $this->view->setHelperPath($this->root .'/application/default/views/helpers');
     $this->layout = Zend_Layout::startMvc(
        array(
                'layoutPath' => $this->root . '/application/default/views/'.$crt_theme.'/layouts',
                'layout' => 'layout'
                )
                );
        $this->registry->set("theme", $crt_theme);
Run Code Online (Sandbox Code Playgroud)

变量$ …

zend-framework

0
推荐指数
1
解决办法
3545
查看次数

标签 统计

zend-framework ×1