Module Layout

Hi guys,

I have created a module to use an administration to the rest of the project but it is defaulting to the main layout files and I want to change my menu.

I have the these files


/protected/modules/admin/views/layouts/main.php

/protected/modules/admin/views/layouts/column1.php

Also AdminModule.php is in


/protected/modules/admin/

with the following code

<?php


class AdminModule extends CWebModule

{

	public function init()

	{

		// this method is called when the module is being created

		// you may place code here to customize the module or the application


		// import the module-level models and components

		$this->setImport(array(

			'admin.models.*',

			'admin.components.*',

		));


                $this->layout = 'main';

	}


	public function beforeControllerAction($controller, $action)

	{

		if(parent::beforeControllerAction($controller, $action))

		{

			// this method is called before any module controller action is performed

			// you may place customized code here

			return true;

		}

		else

			return false;

	}

}

But it will not read the layout files in their. Reads the layout files in


protected/views/layouts/etc

I am not using a theme either, what is wrong?

under your admin module protected/modules/admin

in your view (eg. index.php)

add:


$this->layout = "column1";

in your layout file, (eg. column1.php, column2.php)

change:


<?php $this->beginContent('//layouts/main'); ?>

to:


<?php $this->beginContent('/layouts/main'); ?>

note: single slash

This has not worked I still have my menu from the standard layout folder. Just seems to ignore my admin module folder layout files.

wired, i tested the above code and it works for me.

I bet you might have missed changing column2.php file in your module layout folder?

The following has worked for me:




class AdminModule extends CWebModule

{

        public function init()

        {

                // this method is called when the module is being created

                // you may place code here to customize the module or the application


                // import the module-level models and components

                $this->setImport(array(

                        'admin.models.*',

                        'admin.components.*',

                ));


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

        	$this->layout = '/layouts/main';

        }

...



The module layouts column1 and column2 in views/layouts/




<?php $this->beginContent('/layouts/main'); ?>



Good luck.

Sorry have been away on holiday. Putting $this->layout = "column1"; in the index.php file of my admin modules folder has worked but surely this is not correct. Its not working in in the init function of AdminModule but it is inside the view file.

ok I found the solution,

click here