Question

I am rendering a page with a lot of frames (XHR contentpanes via dojo). This is done through a request to IndexController which sets up regions 'header,left,right,center,footer' with the exception, that center is not filled in with contents. This in turn is set by calling PaneController in menu.onclick. Caveat; search engines indexing service does not get center region contents.. I wish to bypass AJAX loading of center, if user enters via /index/index.

Relevant snippets from 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;
    }
}

Relevant stuff in Pane

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('/');
    }
}

Basically, i need the PaneController to _not render the global layout but call its .phtml view file, once it has been setup with relevant model entries and such.

Any ideas as to how I can achieve this in its most efficient form?

Was it helpful?

Solution

Very well, ill attach the workaround im using here

The forms and the fork-logic i have moved to the model that is coexisting with PanesController. For the IndexController, which will present the default Pane as inline HTML without AJAX - there is a couple of duplicated initializations going on.

So, IndexModel extends the PanesModel - without initializing it. In my index.phtml view (for Index action) i have following code to render the inline html from a pane.

in index controller

$this->view->model = new IndexModel(); // extends PanesModel
$this->view->model->setDefaultProperties($variant, $pagination, ...);

in index view:

$this->partial("panes/main/main.phtml", array("model", $this->model);

and from pane view:

<?php if($this->model->goThisDirection()): ?>
     Switch 1 HTML contents
<?php endif; ?>

Caveat: I also had to not render any form of layout within the pane (dojox contentpanes allows for <script> and <style> tags) - and this ofc ripples to any other pane action of mine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top