Hi,
I was attempting something similar last night. I ended up with the
following solution using ActionStack plugin.
In the *Action you add the lines
$this->_helper->actionStack('breadcrumbs','widget');
$this->_helper->actionStack('sidebar','widget');
This will call these two actions after the initial one is called (I have
done this through the init() in a subclass of Zend_Controller_Action
which all of my action controllers extend.
In the WidgetController
public function sidebarAction()
{
$this->view->module = $this->_getParam('module');
$this->view->controller = $this->_getParam('controller');
$this->view->action = $this->_getParam('action');
$this->render(null, 'sidebar');
}
...
This will render the view script widget/sidebar.phtml (Or whatever your
default is set to) and assign it to the Response object named path
segment to use (if this is null then it gets appended to the content
segment). In my testing the sidebarAction (and other actions called
through Action stack) will have the initial module/controller/action in
the parameters of the action (but not in the request object)
Then in your layout you do
...
<div id="content">
<?=$this->layout()->breadcrumbs?>
<div class="startrow">
<div class="left">
<?=$this->layout()->content?>
</div>
<div class="right">
<?=$this->layout()->sidebar?>
</div>
</div>
</div>
...
However saying all that. Your method might still work if you use the
$this->_getParam('module'); inside your breadcrubsAction. It would be
interesting how other people have dealt with dynamic content/widgets
(breadcrumbs, navigation) also using Zend_Layout.
Cheers,
James
fab2008 wrote:
Hi to everyone, I've almost done with my first ZF project, I used Zend_Layout
for managing website template and I tought that action view helper is the
right choice to render little blocks of dynamic data present in every page
of the site such as the breadcrumbs and a side menubar. So in my
layout.phtml file I have these lines:
...
<div id="content">
<?=$this->action('breadcrumbs', 'widget')?>
<div class="startrow">
<div class="left">
<?=$this->layout()->content?>
</div>
<div class="right">
<?=$this->action('sidebar', 'widget')?>
</div>
</div>
</div>
...
I use the left layout for rendering main content and I wish to render
breadcrumbs and sidebar using an apposite controller. Now I finished the
main functional part of the site and when I try to write breadcrumbsAction
of Widget controller, I discovered that getActionName and getControllerName
always return "breadcrumbs" and "widget".
When I made the layout and the controller structure I tought that I will be
able to detect the controller and action called in bradcrumbs action in
order to fill the view with the right data, but I was wrong, and now I don't
know how to solve this problem with little modification to all my stuff.
Any suggestion on how implement this thing.
Thanks.
--
James Lucas
--
UTS CRICOS Provider Code: 00099F
DISCLAIMER: This email message and any accompanying attachments may contain
confidential information. If you are not the intended recipient, do not
read, use, disseminate, distribute or copy this message or attachments. If
you have received this message in error, please notify the sender
immediately and delete this message. Any views expressed in this message
are those of the individual sender, except where the sender expressly, and
with authority, states them to be the views the University of Technology,
Sydney. Before opening any attachments, please check them for viruses and
defects.