Yii分页没有移到最后一页

时间:2014-04-02 12:15:03

标签: php yii pagination

我在Yii中使用自定义分页。我有33件物品。但是yii分页不适用于最后3项。

示例代码:

            $total = 33;
            $pages =new CPagination($total);
            $pages->setPageSize($this->pagesize);
            $pages->setCurrentPage($page);

            $start = ($pages->currentPage-1)*$pages->pageSize;
            $images = array_slice($images,$start,($pages->pageSize));

1 个答案:

答案 0 :(得分:0)

这是您的代码

    $total = 33;
    $pages =new CPagination($total);
    $pages->setPageSize($this->pagesize); // $this->pagesize = 10

    $start = $pages->currentPage * $pages->pageSize;
    $images = array_slice($images,$start,($pages->pageSize));