PHP Frameworks - Layout Dynamic Menu [closed] PHP Frameworks - Layout Dynamic Menu [closed] codeigniter codeigniter

PHP Frameworks - Layout Dynamic Menu [closed]


Symfony can do what you are looking for using a mix of concepts.

  • Layout - This is the main structure used to decorate a page.
  • Template - This is the main view attached to a URL by the controller.
  • Fragments - Lightweight and uses data you pass to it.
  • Component - Used if you need access to the model, the code is split between presentation and logic.
  • Slot - used to replace a defined section of the layout.

In your case the layout would have the main content included using the template logic which is the core of the view layer and the other items would be either fragments or components depending on how much of the model they would need to access.

The Symfony documentation has a full explanation of this.


Actually, what you want to achieve here can be done with very little deviation from what you have already, using Zend Framework.

For the menu, you can use Zend_Navigation, which allows you to define the tree of the navigation of your site, and create simple menus. I find that populating the Zend_Navigation container in a Front Controller plugin allows you to cache the object easily, so you have little performance worries from traversing your sites tree,

For the ads, you simply use the placeholder view helper, and you can once again use a Front Controller plugin to populate this. Using a plugin has the advantage that the logic of counting impressions and rotating ads is kept seperate from your actions, and easily performs its task across every action.

dustin.cassiday's method of using the action stack is risky, and can lead to massive headaches debugging your apps. and Itay Moav's method is now really redundant due to Zend_Navigation


Each of the PHP libraries you have mentioned have templating and can accomplish what you need.

Pick a library and get to grips with it. It will pay off over time. Templating engines like Smarty are good, but a full framework offers a lot more.