CH6 - Listing the issues in project view

Hello all together,

following the example in the book I’m currently up to realize the listing of issues within the /project/view.

Therefor the question came up, why I’m not able to directly transmit the array of related issues which I recieve when I call $model->issues.

I’m in the file /protected/views/project/view.php


<?php $this->widget('zii.widgets.ClistView', array(

	'dataProvider'=>$model->issues,

	'itemView'=>'/issue/_view',

)); ?>

Is there a way to solve this like I tryd to? Cause in some cases it doesn’t make sense (in my opinion) to requery data within the controller when I can access this data via the $model of the view 'cause the required data is delivered throug relationship. In my opininon it only makes sense to requery the data when I need to apply furthermore filters / criteria.

Does anyone has a solution for this for me? Would be great.

Kind regards, Dominik

As of Yii 1.1.4 (a later version than what the book is using), you could use the CArrayDataProvider and construct it with the array of related model instances. The dataProvider property of CListView needs to be of type IDataProvider. $model->issues is an array of issue model objects, not itself an object that implements IDataProvider.

However, you could try something like:


<?php $this->widget('zii.widgets.ClistView', array(

        'dataProvider'=>new CArrayDataProvider($model->issues),

        'itemView'=>'/issue/_view',

)); ?>

[font="Arial"]And see if this starts to get you what you are looking for.[/font]

Hi jefftulsa,

thanks, yes the CArrayDataProvide works well…:)

Hi I am also greatfull for this example, however how would I go about adding pagination when using this?

in books example it was as simple as:




'pagination'=>array(

 'pageSize'=>1,

),



how do I do that using example above? Has anyone found out?