Confusion Or Maybe Bug With Modules Layout

Hi,

Couple of hours I was struggling setting modules and its child modules layouts. Modules looks like:




'modules'=>array(

           'admin'=>array(

                    'modules'=>array(

                        'user', 'organization'

                    ),

          ...............



My idea is that parent admin and all child modules use admin’s layout declered in AdminModule.php:




public function init()

{

......

 $this->layoutPath = Yii::getPathOfAlias('application.modules.admin.views.layouts');

 $this->layout = 'column1';

........... 

}



http://www.yiiframework.com/doc/api/1.1/CWebModule#layout-detail says:

layout roperty

“he layout that is shared by the controllers inside this module. If a controller has explicitly declared its own layout, this property will be ignored. If this is null (default), the application’s layout or the parent module’s layout (if available) will be used. If this is false, then no layout will be used.”

Looks ok, but in reality this don’t work and here why:

framework/web/CController.php:





public function getLayoutFile($layoutName)

	{


       // modules controller extends components/Controller and inherits layout property

      // whitch is '//layouts/column1' by default

       // so, by default its never empty or null or false


		if($layoutName===false)

			return false;

		if(($theme=Yii::app()->getTheme())!==null && ($layoutFile=$theme->getLayoutFile($this,$layoutName))!==false)

			return $layoutFile;


                //by default this never applies - property not empty

                // in every child modules controller your have to declare layout property empty 


		if(empty($layoutName))

		{

			$module=$this->getModule();

			while($module!==null)

			{

				if($module->layout===false)

					return false;

				if(!empty($module->layout))

					break;

                                // that's ok but...

				$module=$module->getParentModule();

			}

			if($module===null)

				$module=Yii::app();

			$layoutName=$module->layout;

		}

		elseif(($module=$this->getModule())===null) 

			$module=Yii::app();

				

		return

// this always return false if I render view from child module

// it gets layout property from parent but looks for view file in own layout path, not parent


 $this->resolveViewFile($layoutName,$module->getLayoutPath(),Yii::app()->getViewPath(),$module->getViewPath());

	}



Main questions:

  1. Is it bug in documentation or in code? CControler layout

"Defaults to null, meaning the application layout is used. If it is false, no layout will be applied. The module layout will be used if the controller belongs to a module and this layout property is null"

It is ok if in components/Controller.php layout would’nt be declared at all else you have to set null or empty in child modules controller

  1. Is it ok if child modules gets layout property from parent module, but layout view file is search in child’s directory?

Thanks :)