Your problem has little to do with Zend_Layout. The issues resides in
the fact
that MyPlugin::dispatchLoopStartup() will be called regardless of
whether or not
you've disabled Zend_Layout in a certain action. That's why
MyController::menuAction()
will always be executed, as it will always be on the action stack.
One way to solve this is to have a check in your
MyPlugin::dispatchLoopStartup(), like this:
public function
dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
if ($request->getActionName() === 'no-layout') {
return;
}
}
There probably are better ways to do this, but I have no other idea for
the moment.
Hope it helps somehow.
Cheers
On 5/5/2009 13:09, lightflowmark wrote:
Hi - thanks for taking a look at this.
I think the relevant parts of the code are:
In my Front Controller Plugin:
function dispatchLoopStartup
{
$actionStack =
$front->getPlugin('Zend_Controller_Plugin_ActionStack');
$menuAction = clone($request);
$menuAction->setActionName('menu')
->setControllerName('my_controller');
$actionStack->pushStack($menuAction);
}
In MyController:
function menuAction
{
// stuff ...
// menu viewscript renders like<div id=menu>menu item 1, menu item
2</div>
$this->_helper->viewRenderer->setResponseSegment('menu');
}
function withLayoutAction
{
// stuff ...
// withLayout viewscript renders like<div id=withLayout>some
with-layout text</div>
}
function noLayoutAction
{
$this->getHelper('layout')->disableLayout();
// stuff
// noLayout viewscript renders like<div id=noLayout>Some no-layout
stuff here</div>
}
In layout.phtml:
<H1>Menu</H1>
<?= $this->layout()->menu ?>
<H1>Main Content</H1>
<?= $this->layout()->content ?>
If I go to my_controller/withLayout, I get the menu and withLayout div
rendered at the layout placeholders as you'd expect, no problem.
If I go to my_controller/noLayout, I the full output is:
<div id=noLayout>Some no-layout stuff here</div><div id=menu>menu item 1,
menu item 2</div>
The content from menuAction is simply appended to the content from
noLayoutAction, which is exactly *not* what I want!
I'm not sure if I'm doing something wrong, or if this is somehow desired
behaviour, or whether this is in fact broken.
Thanks,
Mark
--
Ionut G. Stan
I'm under construction | http://igstan.blogspot.com/