How To Override A Clinkpager Function For A Clistview?

I have a CListView that requires the links to be generated in a different way from how CLinkPager does it by default. I have narrowed it down to this function in CLinkPager (\framework\web\widgets\pagers\CLinkPager.php):




/**

 * Creates a page button.

 * You may override this method to customize the page buttons.

 * @param string $label the text label for the button

 * @param integer $page the page number

 * @param string $class the CSS class for the page button.

 * @param boolean $hidden whether this page button is visible

 * @param boolean $selected whether this page button is selected

 * @return string the generated button

 */


protected function createPageButton($label,$page,$class,$hidden,$selected)

{

	if($hidden || $selected)

	         $class.=' '.($hidden ? $this->hiddenPageCssClass : $this->selectedPageCssClass);

	return '<li class="'.$class.'">'.CHtml::link($label,$this->createPageUrl($page)).'test</li>';

}



How do I override this function for a single CListView?

do this:

copy CLinkPager.php to protected\components\XLinkPager.php and modify as:


class XLinkPager extends CLinkPager

{

//it's yours to modify, my foot step is zzz

	protected function createPageButton($label,$page,$class,$hidden,$selected)

	{

		if($hidden || $selected)

			$class.=' '.($hidden ? $this->hiddenPageCssClass : $this->selectedPageCssClass);

		return '<li class="'.$class.'">zzz'.CHtml::link($label,$this->createPageUrl($page)).'</li>';

	}

}

in your view file:


//it would be the same for listview

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

	'id' => 'item-grid',

	'pager' => 'XLinkPager', //<== add this

is Yii damn beauty?

She is mighty fine. Thank you for the clear and concise instructions, it works great!