Yii Framework Forum: How to determine ODD elements inside CListView items - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to determine ODD elements inside CListView items Rate Topic: -----

#1 User is offline   slyder 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 14-May 09
  • Location:Russia

Posted 09 April 2010 - 09:46 AM

Hello,

I am using CListView widget:


		<?php $this->widget('zii.widgets.CListView', array(
			'dataProvider' => $hotEstatesProvider,
			'itemView'     => 'index-hot-estate-list-item',
			'htmlOptions'  => array('class' => 'hotAdvertSmall')
		)); ?>


and i want to set different classes per each odd item. How can i determine them inside index-hot-estate-list-item.php file?
Inside file '$this' refers to controller so i could not get any info about current item and widget.

Thanks.
2

#2 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 09 April 2010 - 02:22 PM

View Postslyder, on 09 April 2010 - 09:46 AM, said:

Hello,

I am using CListView widget:


		<?php $this->widget('zii.widgets.CListView', array(
			'dataProvider' => $hotEstatesProvider,
			'itemView'     => 'index-hot-estate-list-item',
			'htmlOptions'  => array('class' => 'hotAdvertSmall')
		)); ?>


and i want to set different classes per each odd item. How can i determine them inside index-hot-estate-list-item.php file?
Inside file '$this' refers to controller so i could not get any info about current item and widget.

Thanks.


($index % 2) ? odd : even

Read more here.

(not tested)
/Tommy
Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
4

#3 User is offline   slyder 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 14-May 09
  • Location:Russia

Posted 12 April 2010 - 04:41 AM

View Posttri, on 09 April 2010 - 02:22 PM, said:

($index % 2) ? odd : even

Read more here.

(not tested)
/Tommy


Thanks! Have not seen this variables before.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users