Each itemView
of a CListView
is passed a few variables automatically, namely:
$this
: refers to the owner of this list view widget. For example, if the widget is in the view of a controller, then$this
refers to the controller.
$data
: refers to the data item currently being rendered.
$index
: refers to the zero-based index of the data item currently being rendered.
$widget
: refers to this list view widget instance.
(emphasis mine)
And each CListView
widget has the property $dataProvider
, and a data provider has the property $data
which is:
an array of the data items currently available (meaning in the current page, with the current sort etc.)
So in a partial itemView
we can access the entire dataset of the dataProvider
, like so:
$widget->dataProvider->data;
For your example, something like this should work:
<?php
if ($index > 0 && $widget->dataProvider->data[$index-1]->name == $data->name):
?>
<b><?php echo $data->name; ?></b>
<?php else:
echo $data->test_message;
?>
<?php endif; ?>