CListView items css class change on the 4th, 8th, etc record.

hello,

is there a way inside the CListView that i can tell itthat for X records change the items css class?

i need to set four records in a row. the problem is that it my design my 4th record should see appended

something like




<div class="span-4 last"> RECORDS DATA HERE </div>

[code]


while all the other ones would just have

[code]

<div class="span-4"> RECORDS DATA HERE </div>



i really need your help on this one, thanks in advance …

PS - i’m using the blueprint.css that ships with Yii.

Probably you can make use of a varialbe named "$index" in the view for the list items.

See the reference : CListView::itemView

thanks alot for the information softark.

you’re saving the day once again.

I used $index to check for the first record and to check for odd and even records, but how do I check for the last record if I don’t know the number of records I have?

The total number of the records can be retrieved from the data provider using getTotalItemCount().

IDataProvider::getTotalItemCount()

And a variable "$widget" can be used to refer to the CListView in the item view script.

CListView::itemView

So, the following should tell you the total item count in the item view script.




$widget->dataProvider->getTotalItemCount();



Thanks for the hint. This should work. In the meantime I resigned to use the CListView and used my own loop through th elements.