Move menu items from layout file


I want to remove the menu items of applications from main.php to somewhere else.


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

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

I dont want to put it in the layout file "main.php". (with a little instruction) Please suggest which file is suited for keeping these items in?


Where do you want to place them afterwards? On all pages or specific ones?

I want it to appear on all pages. I Just dont want the code in the main.php file. I suppose main.php file in the layouts is not suitable for this data.

If we are talking about views/layouts/main.php, then that is your default layout. Unless you specify other layout in the controller (or no layout at all), this file will be used to enclose your generated output (placing the latter at $content placeholder).

Yes we are talking about views/layouts/main.php. mainmenu is a widget which processes the menu items which are passed as parameters from the main.php file. I don’t want to place the code (parameters) for menu items here in the main.php and want to separate it from the layout file. Where can I put that?

I see your question now. I’d put it in the configuration array, under ‘params’ key.

So you can later pass the arguments to the widget as Yii::app()->params[‘myMenuItems’];

Hope this helps.

Hey dude. You can create a file separeted. and them call $this->renderPartial(‘psth/to/view’); on your views…