Hello friend
I got an error followed by Property "News.name" is not defined.
I have 2 table: news and menu
My Controller:
$menu = Menu::model()->findByAttributes(array('alias' => $_GET['alias']));
$criteria1 = new CDbCriteria();
$criteria1->select='t.*';
$criteria1->with = array('menu'=>array('select'=>'menu.name'));
$criteria1->join = 'join menu on t.menu_id = menu.menu_id';
$criteria1->condition = 't.status=1 AND menu.root_id=' . $menu->menu_id;
$criteria1->order = 'menu.menu_id DESC';
$criteria1->limit = 2;
$dataProvider1 = News::model()->findAll($criteria1);
$this->render('category', array(
'dataProvider1' => $dataProvider1,
'menu' => $menu
));
New model
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'menu' => array(self::BELONGS_TO, 'Menu','menu_id'),
);
}
Menu model
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'news' => array(self::HAS_MANY, 'News','menu_id'),
);
}
My view
<?php
foreach($dataProvider1 as $k =>$value){?>
<div class="title"><a href="#"><?php echo $value->name ?></a></div> ERROR HERE
<div class="new-right-content">
<img src="<?php echo $baseUrl . '/' .'upload'.'/'. $value->image ?>" />
<h3><a href="#"><?php echo $value->title ?></a></h3>
</div>
</div>
<?php }?>
Hope you help.thanks