Clistview: Insert Html Between Elements

Hi everyone,

I have a little problem: i’using CListView with infiniteScroll extension to show some photos.

This is the controller

	public function actionIndex()


		$criteria=new CDbCriteria(array(                    

			'order'=>'id DESC',



		$dataProvider=new CActiveDataProvider('Photos', array(










This is the view

$this->widget('zii.widgets.CListView', array(

       'id' => 'photos-list',

       'dataProvider' => $dataProvider,

       'itemView' => '_view',

       'template' => '{items} {pager}',

       'pager' => array(

                    'class' => 'ext.infiniteScroll.IasPager', 


                    'listViewId' => 'photos-list', 

                    'header' => '',


                    'options' => array('history' => false, 'triggerPageTreshold' => 10, 'trigger'=>'More...'),




I’m in trouble becouse I would to display photos like this

|xxxxxxx| |xxxxxxx| |xxxxxxx|

|xxxxxxx| |xxxxxxx| |xxxxxxx|

|xxxxxxx| |xxxxxxx| |xxxxxxx|

|xxxxxxx| |xxxxxxx| |xxxxxxx|

|xxxxxxx| |-button| |xxxxxxx|

|xxxxxxx| |xxxxxxx| |xxxxxxx|

6 photos per page, but the 5th element isn’t a photo, but a button.

Any suggestions?

Thanks a lot!

Try this

<div style="width: 100%;">

$this->widget('zii.widgets.CListView', array(



)); ?>

<div style="clear:both;"></div>


in view

<div style="width: 255px; float: left;border:solid 1px #d4d4d4;margin-left:2em;margin-top: 1em; padding: .5em; height: 12em">

//display content


This isn’t a layout problem (css), but a “concept problem”.

I get 5 elements per page using CListView and infinteScroll, together.

I would to display elements in this way:

element1, element2, element3,

element4, BUTTON, element5

BUTTON isn’t a record, but I have to put it in the middle, everytime I get 6 elements.



Does infinitePager have a default pageSize?

No, extension cannot have default value, because ‘pageSize’=>5 is setted in the Controller (dataProvider)

The extension is Yii 1.1: inifinite-scroll-pager

Could this be the problem? pageSize=>6 or whatever.

If pageSize=>5 I have

photo1, photo2, photo3, photo4, photo5

If pageSize=>6 I have

photo1, photo2, photo3, photo4, photo5, photo6

I would have

photo1, photo2, photo3, photo4, customHtml, photo5

So pageSize=5 is ok in my mind.

Do you understand?

Is it possible?

Ohhh. You WANT the button. I was think that you DIDN’T want the button.

I think you will need to sub-class the CListView and use you own logic to get what you want.

You think is ok to extend the CListView class that we find in /framework/zii/widgets folder. Ok, no problems. I think is funny.

I would an advice on how to…

I could create MyListView class. Where is correct to locate it? In protected/components folder?

Thanks a lot

Yes. standard location would be protected/components. Another option would extensions, i.e. make your own extension.