sfPropelPager 只生成 5 个页面
我正在开发一个 symfony 项目,需要为长列表创建一个分页系统。我使用 sfPropelPager 插件来生成它们。我以这种方式使用它:
我打印不同
标签中的所有页面,并且仅将第一个设置为可见。然后使用 javascript 函数,当单击“下一个”、“上一个”...按钮时,我会显示其他页面。我用来生成页面的函数是这样的: `
$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;`
并且视图代码是:
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());?>
问题是 sfPropelPager 最多只能生成 5 个页面。
你知道我必须在哪里配置它才能显示所有页面吗?谢谢你!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您检查sfPager的来源 你会看到它有一个
$nb_links
参数,告诉你想要多少个链接。默认值为 5。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.分页非常简单 - 这是 Jobeet 教程中的一个很好的例子 -> http://www.symfony-project.org/jobeet/1_4 /Propel/zh/07#chapter_07_list_pagination
Pagination is very straightforward - here is a great example on the Jobeet tutorial -> http://www.symfony-project.org/jobeet/1_4/Propel/en/07#chapter_07_list_pagination