category
id | name | pid | about
77 | TV | NULL | HAI123
78 | Apple | NULL | Hai123
79 | Ipad | 72 | HAi123
80 | Iwatch | 72 | HAi123
product
categoryid | name | about | price
77 | LED | hi123 | 22 USD
77 | LCD | hi123 | 28 USD
78 | i5c | hi123 | 24 USD
78 | i5s | hi123 | 27 USD
I created two tables named category
and product
and category
is the parent table.
i want to show them in CMenu.
i had No problem in showing first level menu by using this code
Yii::import('zii.widgets.CMenu', true);
class ActiveMenu extends CMenu
{
public function init()
{
// Here we define queray conditions.
$criteria = new CDbCriteria;
$criteria->condition = 'pid IS NULL';
// $criteria->order = '`position` ASC';
$items = Category::model()->findAll($criteria);
foreach ($items as $item)
$this->items[] = array('label'=>$item->name, 'url'=>'index.php?r=category/category/view&id='.$item->id);
parent::init();
}
but i stucked in sub menu creation.
the concept to create sub menu is wheni click TV on Main Menu it will take id as 77
and search in product table for 77 and display LED and LCD behind it…
please help me any way…