What is best practice to create dynamic sidebar or other non content layout places with zend framework. At this moment I created controller witch i called WidgetsController. In this controller i defined some actions with 'sidebar' response segment for my sidebar and in IndexController i call them with $this->view->action(); function but I don't think that is a best practice to create dynamic sidebar. Thanks for your answers.
You question doesn't provide many details. Generally, I'd say load the sidebar as view template, via the render/partial methods of the view. So from inside a view:
//$data is dynamic data you want to pass to the sidebar
echo $this -> partial('/path/to/sidebar.phtml',array('menuitems' => $data));
And then sidebar could process that dynamic data:
//sidebar.phtml
<div id="sidebar">
<?php foreach($this -> menuitems as $item) : ?>
<a href="<?php echo $item['url']; ?>"><?php echo $item['title']; ?></a>
<?php endforeach; ?>
</div>
If you need extra functionality, you could create a dedicated view helper to handle it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With