Posts tagged: module

Zend Framework Per Module Layout Settings – Follow Up

By , Tuesday 16th February 2010 8:48 pm

As a follow up to my previous post on per module based layout settings for Zend Framework, I’ve updated the code to require less configuration then before (not that it required more that a few lines in your application configuration!).
Continue reading 'Zend Framework Per Module Layout Settings – Follow Up'»

Zend Framework Per-Module based settings

By , Friday 1st January 2010 10:40 pm

I’ve created a followup to this post which requires less configuration, please see Module Based Layout – Zend Framework.

When using the zend framework with modules, its obvious that if you’re running various (sub-)sites off the same application you don’t necessarily want the same layout scripts for each part. I decided to go with the following site structure:


The problem was setting up the layout scripts on a per-module basis. The answer came through using an Action Helper. Setting up the layouts on a per-module basis involves three steps:

  1. Application.ini (or similar configuration setup):
    admin.resources.layout.layoutPath = APPLICATION_PATH "/modules/admin/layouts/scripts"
    default.resources.layout.layoutPath = APPLICATION_PATH "/modules/default/layouts/scripts"
    member.resources.layout.layoutPath = APPLICATION_PATH "/modules/member/layouts/scripts"
    affiliate.resources.layout.layoutPath = APPLICATION_PATH "/modules/affiliate/layouts/scripts"
  2. Create your Action Helper:
     * Sets the layout path on a per-module basis
     * @author Lloyd Watkin <>
     * @since  2010-01-01
    class Pro_Controller_Action_Helper_SetLayoutPath
        extends Zend_Controller_Action_Helper_Abstract
         * Sets layout path based on module
        public function preDispatch()
        	$module = $this->getRequest()->getModuleName();
    	    if ($bootstrap = $this->getActionController()
    	                       ->getInvokeArg('bootstrap')) {
    	        $config = $bootstrap->getOptions();
    	        if (isset($config[$module]['resources']['layout']['layoutPath'])) {
    	            $layoutPath =
  3. And lastly boostrap the action helper:
         * Sets up layout scripts on a per-module basis
        protected function _initLayoutHelper()
    	    $layout = Zend_Controller_Action_HelperBroker::addHelper(
    	        new Pro_Controller_Action_Helper_SetLayoutPath());

Panorama Theme by Themocracy

2 visitors online now
1 guests, 1 bots, 0 members
Max visitors today: 8 at 07:11 am UTC
This month: 15 at 12-11-2017 04:06 pm UTC
This year: 45 at 02-01-2017 10:28 pm UTC
All time: 130 at 28-03-2011 10:40 pm UTC