I have created a UserMenu Component which extends CPortlet as shown in yii guide. But the Links are hardcoded. May i know how shall fetch the links from database table and dislpay it in view.
Thank You.
I have created a UserMenu Component which extends CPortlet as shown in yii guide. But the Links are hardcoded. May i know how shall fetch the links from database table and dislpay it in view.
Thank You.
<?php
Yii::import('zii.widgets.CMenu');
class DbMenu extends CMenu
{
public function init()
{
$this->items = $this->getMenu();
parent::init();
}
private function getMenu()
{
$criteria = new CDbCriteria(array(
'order' => 'position ASC',
));
$menu = array();
$items = MenuLink::model()->findAll($criteria);
if($items) {
$menu[] = array('label'=>'|','url'=>array());
}
foreach ($items as $item)
{
$menu[] = array('label'=>$item->title,'url'=> $item->url, 'linkOptions' => array('title' => $item->description));
}
return $menu;
}
}
?>
Thanks a lot dude… Will try to work around with this…
How to render an view.?