module base top menu change


I have two modules (example: Garden and Park). How to set module base top menu? After login, if user click Garden then only see Garden base top manu and logout link?


You can use a different layout for each module, or use a single layout and check with:

if (Yii::app()->controller->module && Yii::app()->controller->module->id=='garden')

It will be appreciated if you send me and example code to use a single layout …


I have changed the main.php(layout) but not working.

<div id="mainmenu">

		<?php $this->widget('zii.widgets.CMenu',array(


				array('label'=>'Home', 'url'=>array('/site/index')),

				array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),

				array('label'=>'Contact', 'url'=>array('/site/contact')),

				array('label'=>'Garden', 'url'=>array('/Garden'), 'visible'=>!Yii::app()->user->isGuest),

				if (Yii::app()->controller->module && Yii::app()->controller->module->id=='UVP'){

				array('label'=>'Test1', 'url'=>array('/Garden/Test1'), 'visible'=>!Yii::app()->user->isGuest),


				elseif (Yii::app()->controller->module && Yii::app()->controller->module->id=='Park'){

				array('label'=>'Test2', 'url'=>array('/Park/Test2'), 'visible'=>!Yii::app()->user->isGuest),


				array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),

				array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)


		)); ?>

	</div><!-- mainmenu -->

Hi nemo,

I am trying to do the same thing u tried to achieve. Did u manage to make your code work? I would really appreciate it if u could send me the code…