2

我创建一个带有分页的模块,当我使用 create_pagination() 助手时,我在链接中得到一个问号。限制已设置为 6,因此我希望链接按 0、6、12、18 的顺序排列,但我得到 1?、2?、3?。

这是正在生成的内容:

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

这是我所期待的:

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

我在控制器中传递的代码是;

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 );

   ...
}

任何帮助将不胜感激。

4

1 回答 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();

   ...
}
于 2013-08-18T22:56:16.787 回答