Add New Menu Item

I am new to yii.Please anybody can tell me how to add new menu to menu bar like About us, Login,…(in default) in detail.

Hi Sachi you can edit your main.php layout under app/protected/views/layout/main.php it looks like this by default




<div id="mainmenu">

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

			'items'=>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'=>'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 -->




<div id="mainmenu">

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

			'items'=>array(

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

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


// new menu items depends where you want them i am gonna ad one after the about us page 

// the format is label is your menu name that appears in menu and url is the link 


                                array('label'=>'New Page', 'url'=>array('/site/new_page',)),


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

				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 -->

hope it helps you

also read up on blog tutorial here is useful resource for yii beginners

http://www.yiiframework.com/wiki/250/yii-for-beginners

Thank you very much alirz23.But I add code as you said like behind.

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

		'items'=&gt;array(


			array('label'=&gt;'Home', 'url'=&gt;array('/site/index')),


			array('label'=&gt;'Gallery', 'url'=&gt;array('/site/gallery',)),


			array('label'=&gt;'About', 'url'=&gt;array('/site/page', 'view'=&gt;'about')),...

But my web app menu bar didn’t show that Gallery menu item.How I show that Gallery in menu bar like Home,About Us,…

your code looks ok to me, what file did you change and please can your post your code from view and controller

I didn’t change any file.I change that layout/main.php only as you said .But it did’t show.Therefore I create new app and did like before.That’s work.I don’t know what the error is.But I get it in my new web app.Thanks alirz23.