sfPropelPager 只生成 5 个页面

发布于 2024-12-13 16:34:34 字数 2486 浏览 6 评论 0原文

我正在开发一个 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&oacute;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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘逸的'云 2024-12-20 16:34:34

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.

夜深人未静 2024-12-20 16:34:34

分页非常简单 - 这是 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文