大佬教程收集整理的这篇文章主要介绍了cakephp-2.3 – cakephp paginator helper在删除最后一页的最后一条记录时显示错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<?php echo $this->Paginator->prev ($this->Html->image('prev.png'),array('escape' => falsE),array(),null,array('class' => 'prev')); echo $this->Paginator->counter ('Page {:pagE} of {:pages},@R_12_10586@l Records {:count}'); echo $this->Paginator->next($this->Html->image ('next.png'),array('class' => 'next')); ?>
但是,在$this-> request-> params [‘paging’]中可以使用分页参数的文档不正确,因为这些是在抛出异常后定义的. (两个月前Cakephp 2.4.x中已修复此问题)
因此,要获得您想要的效果,您可以在控制器中执行以下操作:
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 } } }
以上是大佬教程为你收集整理的cakephp-2.3 – cakephp paginator helper在删除最后一页的最后一条记录时显示错误全部内容,希望文章能够帮你解决cakephp-2.3 – cakephp paginator helper在删除最后一页的最后一条记录时显示错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。