amichelins
(Amichelins)
1
HI all
I am new to Yii…
I tring use de CLinkPager, but in this moment i have some problems with it…
I have this links
Page 1 /sri/index.php/comercial/pedidos/pesquisa
Page 2 /sri/index.php/comercial/pedidos/pesquisa/page/2
Page 3 /sri/index.php/comercial/pedidos/pesquisa/page/3
/comercial/pedidos/pesquisa action is the same when i get de form for the search and for the result of search…
Only the view is diferent.
Action /sri/index.php/comercial/pedidos/pesquisa
Views: Pesquisa.php for form, and Resultado.php search result.
This /sri/index.php/comercial/pedidos/pesquisa is url for the search form, when i click page 1 in the CLinkPager, i got a form and not de first page.
how to change this /sri/index.php/comercial/pedidos/pesquisa to
this /sri/index.php/comercial/pedidos/pesquisa/page/1 ?
Thanks in advance
amichelins
(Amichelins)
2
I find the solution tu this problem, i extend some classes.
Here de code:
I extend CLinkPager
class CLinkPagerEX extends CLinkPager
{
public function createPageButtons()
{
if(($pageCount=$this->getPageCount())<=1)
return array();
list($beginPage,$endPage)=$this->getPageRange();
$currentPage=$this->getCurrentPage(false); // currentPage is calculated in getPageRange()
$buttons=array();
// first page
$buttons[]=$this->createPageButton($this->firstPageLabel,0,$this->firstPageCssClass,$currentPage<=0,false);
// prev page
if(($page=$currentPage-1)<0)
$page=0;
$buttons[]=$this->createPageButton($this->prevPageLabel,$page-1, $this->previousPageCssClass, $currentPage<=0,false);
// $buttons[]=$this->createPageButton($this->prevPageLabel,$page, //$this->previousPageCssClass,$currentPage<=0,false);
// internal pages
for($i=$beginPage;$i<=$endPage;++$i)
$buttons[]=$this->createPageButton($i+1,$i,$this->internalPageCssClass,false,$i==$currentPage - 1);
// $buttons[]=$this->createPageButton($i+1,$i,$this->internalPageCssClass,false,$i==$currentPage);
// next page
if( ($page=$currentPage+1 )>=$pageCount-1)
$page=$pageCount-1;
$buttons[]=$this->createPageButton($this->nextPageLabel,$page-1,$this->nextPageCssClass, $currentPage>= $pageCount-1,false);
//$buttons[]=$this->createPageButton($this->nextPageLabel,$page,$this->nextPageCssClass,$currentPage>=$pageCount-1,false);
// last page
$buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1, $this->lastPageCssClass, $currentPage>=$pageCount-1,false);
return $buttons;
}
}
I extend CPagination
class CPaginationEX extends CPagination
{
public function createPageUrl($controller,$page)
{
$params=$this->params===null ? $_GET : $this->params;
//if($page>0) // page 0 is the default
$params[$this->pageVar]=$page + 1;
// $params[$this->pageVar]=$page+1;
//else
// unset($params[$this->pageVar]);
return $controller->createUrl($this->route,$params);
}
}
PROBLEM SOLVED.