I could be slightly incorrect, but it is my understanding that these are two
completely separate plugins. The layout plugin will be executed
postdispatch, whereas the actionstack is a queue of requests that get
dispatched.

With this logic, you've already fired off your actionstack before you had
time to disable the layout ( not that they are connected ).  I think you
should just unregister the plugin predispatch if the request meets a certain
condition you want. 

I.E.

If ( is Ajax Request ) {
   $fc->unregisterPlugin(ActionStack);
}

I think this actual example is incorrect, however the logic I believe is
correct.



Sam Davey wrote:
> 
> 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-tp18005744p18024106.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to