Hello, I have problems with CPagination class. I have decided to extend it. I create file CustomPager.php in folder
protected/components
Yii::import('system.web.CPagination');
class CustomPager extends CPagination
{
public function createPageUrl($controller, $page)
{
$params = $this->params === null ? $_GET : $this->params;
if($page > 0)
{
$params[$this->pageVar] = $page+1;
}
else
{
unset($params[$this->pageVar]);
}
if(isset($_POST) && count($_POST) > 0)
{
foreach($_POST as $key => $value)
{
$value = intval($value);
if($value > 0)
{
$params[$key] = $value;
}
}
}
return $controller->createUrl($this->route, $params);
}
}
in main.php I have loaded this class
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
'application.components.CustomPager.*',
),
in controller
//Pagination
$pages = new CustomPager($item_count);
$pages->setPageSize($viewTypeData[2]);
//Render of view
$this->render($viewTypeData[1], array(
'data'=>$data,
'item_count'=>$item_count,
'page_size'=>$viewTypeData[2],
'pages'=>$pages,
'page'=>$page
));
but it doesn’t work.