2013-08-18 155 views
2

当我使用create_pagination()助手创建一个带分页模块时,我在链接中得到一个问号。限制已被设置为6,所以我期望链接按照0,6,12,18的顺序排列,但是Im得到1?,2?,3 ?.PyroCMS分页不起作用

这是正在生成什么:

<a href="http://site.com/mymodule/page/?">1</a> 
<a href="http://site.com/mymodule/page/2?">2</a> 

这是II期待:

<a href="http://site.com/mymodule/page/">1</a> 
<a href="http://site.com/mymodule/page/6?">2</a> 

通过在控制器中的代码Im为;

public function index($offset = 0) 
{ 

    $limit = 6; 
    $total_items = $this->mymodel_m->count_all(); 
    $items = $this->mymodel_m 
         ->limit($limit)->offset($offset ) 
         ->get_all(); 

    $data->pagination = create_pagination('mymodule/page/', $total_items, $limit, 3); 

    ... 
} 

任何援助将不胜感激。

+1

我有同样的问题,我已经“修理”它用笨 –

回答

3

像这样的东西应该工作。

public function index() 
{ 
    $limit = 6; 
    $total_items = $this->mymodel_m->count_all(); 
    $pagination = create_pagination('mymodule/page/', $total_rows , $limit, 3); 

    $items = $this->mymodel_m 
         ->limit($pagination['limit'], $pagination['offset']) 
         ->get_all(); 

    ... 
} 
+0

定期分页抱歉过了这么久才证实了这一点,我想这一点在不久前,它没有工作,现在我再次审查它现在它工作。我之前肯定有一个错误,那就是干扰。是的,这工作很好,非常感谢。 – IEnumerable

+0

@IEnumerable〜很高兴听到! NP! – Alireza