Jump to content

Dynamic Sidebar Content w/ Zend Framework


Recommended Posts



I'm a complete newb trying to learn the zend framework. I set up a 'master page' with zend_layout, and the "content" section is working fine with my controllers/views. However, I want my sidebar to be dynamic as well, and I can't figure out how. My directory structure looks like this:














My simplified layout.phtml file looks like this:

<div id="content">
     <?php echo $this->layout()->content; ?>
<div id="navigation">
     <?php echo $this->layout()->sidebar; ?>



This is an example of one of my controllers:

class IndexController extends Zend_Controller_Action 

public function init(){
	$response = $this->getResponse();
                $response->insert('sidebar', $this->view->render('sidebar.phtml'));

        //other functions below



My sidebar.phtml file looks something like this:

<div class="navigation">
<h1>Recent Posts</h1>
	<?php echo $this->iWantToBeDynamic; ?>
<div class="navigation">
	<?php echo $this->iWantToBeDynamic; ?>


Is it possible to add a controller to my sidebar.phtml file? If so, how, if not, what is the best possible way to make this sidebar dynamic?


Link to post
Share on other sites

Ok, I made a "classes" folder in my application directory, and made a "Sidebar" class, that accesses a model.


Then I created an instance of that Sidebar class in my sidebar.phtml view.


That's the best I could come up with, seems to work fine. Zend is overwhelming me.

Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.