dinamic menu


is there a way to customize application.components.MainMenu for make it dinamically with dropdown, or do I have to programming as I want?

at this moment I have


foreach($list as $label => $url):

    $menu[$i]['label'] = $label;

    $menu[$i]['url'] = array('/'.$url);

    $menu[$i]['visible'] = $visible;







that works but what whether i want to make dropdown menu?

great framework!!

The MainMenu component included is mainly for demo purpose.

I don't think it is very suitable to be extended to support css or js-powered menus.

I renamed it from MainMenu to Menu and extended the code:


You may use it like this:


<?php $this->widget('application.components.Menu',array(


		array('Home', array('site/index')),

		array('Contact', array('site/contact')),

		array('Users', array('user/list')),

		array('Posts', array('post/list')),

		array('News Archive', array('post/news')),

		array('Groups', array('group/list'), 'visible'=>Yii::app()->user->hasAuth(Group::ADMIN)),


	'view' => 'mainMenu' //the view to use to render the menu, contained in /protected/components/views

)); ?>

Example of a menu view: http://code.google.c…ws/mainMenu.php

You may then change the view to display it in any way you want.

Did you try this extension?

I didn't do it until today. Maybe tomorrow


While we're on the topic of the MainMenu component, where does it's color get set?  It's not in main.css (at least as far as I can see).

I believe the color is part of the background image

thank you so much for the answer, very helpful! cheers