Hi,

I am currently putting togther a site using 1.5 and I am finding the
Framework very powerful.  However I am having a problem with the
Zend_Layout/Action Stack logic that is hindering my progress.

Basically I am adding controller/actions associated with the layout to the
action stack.  It all works when using the the layout but when I disable the
layout the action stack output is still sent to the browser even though they
are associated with a layout placeholder.

THE PROBLEM IN DETAIL

I have coded a plugin called ActionSetup

class My_Controller_Plugin_ActionSetup extends
Zend_Controller_Plugin_Abstract
{
        public function dispatchLoopStartup(Zend_Controller_Request_Abstract
$request)
        {
                $front = Zend_Controller_Front::getInstance();
                if(!$front->hasPlugin('Zend_Controller_Plugin_ActionStack')) {
                        $actionStack = new Zend_Controller_Plugin_ActionStack();
                        $front->registerPlugin($actionStack, 97);
                } else {
                        $actionStack = 
$front->getPlugin('Zend_Controller_Plugin_ActionStack');
                }
                
                $quickAccessAction = clone($request);
                $quickAccessAction->setActionName('quick-access')
                                        ->setControllerName('nav');
                $actionStack->pushStack($quickAccessAction);
                
                $shopAccessAction = clone($request);
                $shopAccessAction->setActionName('shop-access')
                                        ->setControllerName('nav');
                $actionStack->pushStack($shopAccessAction);

                           etc... 
                 }
}

I have then adjusted my controller scripts accordingly to ensure that these
actions get loaded up into the relevant Zend_Layout placeholder

    public function quickAccessAction()
        {
                $link_array = array(
                        ...
                        );
                $this->view->quick_access_links = $link_array;
                
                $this->_helper->viewRenderer->setResponseSegment('quickAccess');
        }

And this gets included in the layout view script using this process:

<?php echo $this->layout()->quickAccess; ?>

This all works fine.  However I am now working on pages that do not require
the layout functionality so the layout script should be ignored and any
ActionStack output relating to Zend_Layout placeholders should not be
outputted.

I thought it would be a simple case of including the following code in the
action that doesn't require the layout
$this->_helper->layout()->disableLayout();

This does indeed stop the layout from rendering and the view script relating
to the action is displayed...  HOWEVER... all of the action stack views are
also rendered one by one and are output after the action/view I actually
require.

Why soes this happen when they are related to Layout placeholders?

How do I disable these action stacks when the layout is not called?

Where should the logic be?  Should it be in the plugin?

Any ideas?  How do other people implement this type of Layout problem where
you need complex controller/action included as placeholders in the layout
script?  The plugin/action stack seems to work very well... but I need
control over when the action stack should be used... i.e. not used when the
Layout is disabled.

Thanks,

Sam
-- 
View this message in context: 
http://www.nabble.com/Zend_Layout---Disable-action-stack-output-tp18005744p18005744.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to