2

Im creating a module with pagination, when I use the create_pagination() helper I am getting a question mark in the links. The limit has been set to 6 so I expect the links to be in sequence like 0,6,12,18 but Im getting 1?,2?,3?.

This is what is being generated:

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

This is what iI was expecting:

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

The code Im passing in the controller is;

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

   ...
}

Any assistance would be greatly appreciated.

IEnumerable
  • 3,610
  • 14
  • 49
  • 78

1 Answers1

3

Something like this should work.

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

   ...
}
Alireza
  • 5,444
  • 9
  • 38
  • 50
  • sorry It took so long to confirm this, I tried this a little while ago and it didnt work, now I reviewed it again and it now works. I must have had a bug earlier on that was interfering. Yes this works great and thanks very much. – IEnumerable Sep 18 '13 at 06:10
  • @IEnumerable ~ Glad to hear that! np! – Alireza Sep 18 '13 at 06:15