yii - CMenu URL attribute usage when dynamicaly adding menu items? -


not sure if it's best practice, wish have menu on layout view , pass url parameter value should retrieve data.

the menu like:

<ul id="menu"> <li>districta</li> <li>districtb</li> <li>districtc</li> </ul> 

so like:

'url'=>array('/event/geteventsbydistrict', 'district'=>id), 

is there better way it?

i mean, doing this, believe, if new district gets added database, should edit menu hand, placing corresponding id there ? isn't there way retrieve id database, that, every time menu rendered, may sure that new item link appropriate id of new (just added district?) ?

does makes sense you?

it seems way of creating wrapper class or ?

perhaps districts not example, don't change often, let's imagine changes often.

please advice

if understand question correctly, should work, assuming district model has name property.

$districts = districtmodel::model()->findall(); $menu = array(); foreach($districts $district) $menu[] = array('label'=>$district->name, 'url'=>array('event/geteventsbydistrict', 'district'=>$district->id));  $this->widget('zii.widgets.cmenu', array(     'items'=>$menu )); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -