Hi all,
I’m pretty new to Yii an am a bit stuck at the moment. I do have two database tables. One with categories and another one with different items. What I want to achieve is a view similar to the following:
-
data from category table (title, text, etc.)
-
entry from item table
-
another entry from item table
-
-
data from category table (title, text)
-
entry from item table
-
another entry from item table
-
So I was thinking along the lines of specifying an actionIndex in the controller with two CActiveDataProvider for the two tables. And then use the two providers in the respective views in a CListView (first goes into index.php and the second into _view.php). That does not seem to work and I’m not sure if that’s even the best approach.
Controller ActionIndex:
public function actionIndex() {
$simulation=new CActiveDataProvider('Category');
$simUrls=new CActiveDataProvider('Items');
$this->render('index',array(
'Category'=>$category,
'Items'=>$items,
)); }
View index.php
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$category,
'itemView'=>'_view',
)); ?>
_view.php
<?php
$box = $this->beginWidget('bootstrap.widgets.TbBox', array(
'title' => CHtml::encode($data->title). ' ('.CHtml::encode($data->cve).')',
));
?>
==>> Here would be the code for the items from the second table...
<?php $this->endWidget();?>
Any insight or hint into the right direction would be much appreciated.
Many thanks,
Hugo