3

我正在做一个 symfony 项目,需要为长列表创建一个分页系统。我使用 sfPropelPager 插件来生成它们。我这样使用它:

我用不同的标签打印所有页面,<div>并且只设置第一个可见。然后使用 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 个页面。

你知道我必须在哪里配置它才能显示所有页面吗?谢谢你!

4

2 回答 2

3

如果你检查sfPager 的来源,你会看到它有一个$nb_links参数,告诉你想要多少个链接。默认值为 5。

于 2011-11-02T15:15:00.427 回答
0

分页非常简单 - 这是 Jobeet 教程的一个很好的例子 -> http://www.symfony-project.org/jobeet/1_4/Propel/en/07#chapter_07_list_pagination

于 2011-11-02T14:58:27.480 回答