开发者

CodeIgniter Pagination Problem

I am using codeigniter and its pagination class. It works perfectly and it looks something like this:

« First < 1 2 3 4 5 > Last »

Here is my code:

$this->load->library('pagination');
$config['base_url'] = base_url().'controlpanel/';
$config['first_link'] = 'First';
$config['total_rows'] = $count;
$config['per_page'] = '3'; 
$this->pagination->initialize($config); 
$data['pagination'] = $this->pagination->create_links();
$this->load->view('controlpanel', $data);

I have this in my routes:

$route['controlpanel/(:num)'] = "controlpanel/index/$1";

However, whenever I get to a differentpage i.e. controlpanel/3 - the number 1 is always bold - it should change to 2 or 3 etc!

Why doesn't it?

When I change the $config['base_url']开发者_高级运维 to base_url().'controlpanel/page' then does the pagination work correctly by boldening the correct number - but the link 1 points to the URL controlpanel/page which is the wrong page for me as the base is just controlpanel.

Thanks all for any help.


The pagination class should check the second parameter, not the third(default).

Add this to the config array to change this:

$config['uri_segment'] = '2'; 

This won't change anything but be helpful in creating the url needed. change this :

$config['base_url'] = base_url().'controlpanel/';

to this:

$config['base_url'] = site_url('controlpanel');


Also dont forget to check out for.. $inboxMessageCount this value set from the controller

$config['total_rows'] = $inboxMessageCount;

If this value set, is less than the limit value, then pagination will not be displayed.


Also put this line

$config['uri_segment'] = 3;


$config['first_tag_open']  = '<li>';

$config['first_tag_close'] = '</li>';

$config['first_url'] = site_url('your controller url');

put $config['first_url'] like this to make working of your first tag url

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜