Model view controller 在Zend中呈现局部视图,以便将html添加到路由操作布局

Model view controller 在Zend中呈现局部视图,以便将html添加到路由操作布局,model-view-controller,zend-framework,partial-views,php,zend-framework-mvc,Model View Controller,Zend Framework,Partial Views,Php,Zend Framework Mvc,我正在呈现一个包含大量框架的页面(通过dojo显示XHR内容窗格)。这是通过对IndexController的请求来完成的,该请求设置了区域的标题、左、右、中心、页脚,但该中心没有填写内容。依次通过调用menu.onclick中的PaneController进行设置。警告;搜索引擎索引服务未获取中心区域内容。。如果用户通过/index/index输入,我希望绕过中心的AJAX加载 IndexController中的相关代码段: class IndexController extends Zend

我正在呈现一个包含大量框架的页面(通过dojo显示XHR内容窗格)。这是通过对
IndexController
的请求来完成的,该请求设置了区域的标题、左、右、中心、页脚,但该中心没有填写内容。依次通过调用menu.onclick中的
PaneController
进行设置。警告;搜索引擎索引服务未获取中心区域内容。。如果用户通过/index/index输入,我希望绕过中心的AJAX加载

IndexController中的相关代码段:

class IndexController extends Zend_Controller_Action {
    public function indexAction() {
        $this->indexModel = $this->view->indexModel = new Application_Model_Index();

        // Goal is to render "/pane/main/" action and capture the HTML
        $this->view->mainPane = (string) $this->renderPaneMain();
        return $this->render();
    }
    public function renderPaneMain() {
        // ActionStack ?
        // action() ?
        return $HTML;
    }
}
窗格中的相关内容

class PaneController extends Zend_Controller_Action {

    public function preDispatch() {
        // will only return a contentpane, dont render layout 
        if ($this->getRequest()->isXmlHttpRequest()) {
            $this->_helper->layout()->disableLayout();
            $this->view->doLayout = true;
        }
    }
    public function mainAction() {
            this.render("main.phtml");
    }
    public function init() {
        $this->panesModel = new Application_Model_Panes();
        $variant = $this->getRequest()->getParam('variant', '');
            // routing variables need to be set, how?
        if (empty($variant))
            $this->_redirect('/');
    }
}
基本上,我需要PaneController不呈现全局布局,而是调用它的.phtml视图文件,一旦它使用相关的模型条目等进行了设置


关于如何以最有效的形式实现这一点,有什么想法吗?

很好,我将在这里附上我使用的解决方法

我将窗体和fork逻辑移到了与PanesController共存的模型中。对于IndexController,它将默认窗格显示为不带AJAX的内联HTML-有两个重复的初始化正在进行

因此,IndexModel扩展了PanesModel,而不初始化它。在我的index.phtml视图(用于索引操作)中,我有以下代码从窗格呈现内联html

索引控制器 在索引视图中: 和从窗格视图:

切换1 HTML内容
警告:我还必须在窗格中不呈现任何形式的布局(dojox contentpanes允许
标记),而这会影响我的任何其他窗格操作

$this->view->model = new IndexModel(); // extends PanesModel
$this->view->model->setDefaultProperties($variant, $pagination, ...);
$this->partial("panes/main/main.phtml", array("model", $this->model);
<?php if($this->model->goThisDirection()): ?>
     Switch 1 HTML contents
<?php endif; ?>