dsk710351 2014-07-28 07:47
浏览 20
已采纳

在cakephp中显示分页项目的最后一页

If requesting for a page say page number 3 in paginated items of a table in cakephp, which is having only 2 pages, how do we show the last page ie page number 2?

  • 写回答

1条回答 默认 最新

  • dst2007 2014-07-28 07:52
    关注

    I found out the solution here:-

    cakephp paginator helper shows error when delete the last record from the last page

    public function index() {
        try {
            $paginatedData = $this->Paginator->paginate();
        } catch (NotFoundException $e) {
            //get current page
            $page = $this->request->params['named']['page'];
            if( $page > 1 ){
                //redirect to previous page
                $this->redirect( array( "page" => $page-1 ) );
            }else{
                $paginatedData = array(); //no data to paginate so use empty array()
                                          //you will have to check for this in the view and no longer display the pagination links, since they will NOT be defined
            }
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法