i'm working on a symfony project and needed to create a paging system for long lists. I used sfPropelPager plugin to generate them. I'm using it this way:
I print all the pages in diferent <div>
tags and only set visible the first. Then whith a javascript function, i show the other pages when clicking on next, prev, ... buttons.
the function i use to generate the pages is this: `
$pager = new sfPropelPager('SysLogTbl',sfConfig::get('sfPropelPagerLines'));
$c = new Criteria();
$c->add('codigo_maestro',$this->getCodigoMaestro());
$c->add('codigo_registro',$id);
$c->addDescendingOrderByColumn('fecha_log');
$pager->setCriteria($c);
$pager->init();
return $pager;`
and the view code is:
foreach($pager->getLinks() as $page){
echo'<div id="logpage'.$page.'" class="logpages" style="width:100%;';
if($page!=1){echo ' display:none';}
echo '">';
$pager->setPage($page);
$pager->init();
$results= $pager->getResults();
echo '<table class="none_list" id="list">';
echo "<thead>";
echo "<td width='8%'>Usuario</td><td width='8%'>Acción</td>";
echo "<td width='13%'>Campo</td><td width='25%'>Valor Antiguo</td>";
echo"<td width='25%'>Nuevo valor</td><td width='21%'>TimeStamp</td>";
echo "</thead>";
foreach($results as $log){
echo '<tr id="'.$log->getCodigoLog().'" >';
< here goes each entry in the page display, not relevant >
}
echo '</table>';
echo "<div style='float:left'>";
echo image_tag('first.png',array('class'=>"first"));
echo image_tag('previous.png',array('class'=>"previous"));
echo "</div>";
foreach($lista->getLinks() as $page){
echo "<div class='logindex' id='".$page."' style='float:left; cursor:pointer'>";
if($page == $lista->getPage()){
echo "<b>".$page."</b>";
}else{
echo $page;
}
echo "</div>";
}
echo image_tag('next.png',array('class'=>"next"));
echo image_tag('last.png',array('class'=>"last"));
echo '</div>';
$lista->setCursor($lista->getNextPage());
}
$lista->setCursor($lista->getFirstPage());?>
The problem is sfPropelPager only generates at most 5 pages.
Do you know where must i configure this to show all the pages?? thank you!
If you check the source of sfPager you'll see it has a $nb_links
parameter that tells how many links you want. The default is 5.