我正在渲染一个有很多帧的页面(XHR内容窗格通过dojo)。这是通过IndexController
请求完成的,该请求设置区域"页眉,左,右,中心,页脚",但该中心没有填充内容。这反过来又通过在menu.onclick中调用PaneController
来设置。警告;搜索引擎索引服务不获取中心区域内容。我希望绕过中心的 AJAX 加载,如果用户通过/index/index 输入。
来自 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 来_not渲染全局布局,但在设置了相关模型条目等后调用其 .phtml 视图文件。
关于如何以最有效的形式实现这一目标的任何想法?
很好,请在此处附加
解决方法表单和分支逻辑我已经转移到与PanesController共存的模型中。对于 IndexController,它将默认窗格显示为没有 AJAX 的内联 HTML - 正在进行几个重复的初始化。
因此,IndexModel 扩展了 PanesModel - 无需初始化它。在我的 index.phtml 视图(用于索引操作)中,我有以下代码从窗格呈现内联 html。
在索引控制器中
$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; ?>
警告:我还必须不要在窗格中渲染任何形式的布局(dojox contentpanes 允许<script>
和<style>
标签) - 这个 ofc 会波及到我的任何其他窗格操作。