Welcome Guest, Not a member yet? Register   Sign In
Pagination current URL.
#1

[eluser]sahanlak[/eluser]
This is the config code for the pagination.
Code:
$this->load->library('pagination');

            $config['base_url']="http://domain.net/index.php/admin/partner/$ID/";
            $config['total_rows']=5;
            $config['per_page']=2;
            $config['num_links']=20;
            $config['cur_tag_open'] = '<b>';
            $config['cur_tag_close'] = '</b>';


        $this->pagination->initialize($config);

$ID is an integer. The problem is pagination wont select the current page, its always selecting the number 1.

Why is that?
#2

[eluser]Thomas Edwards[/eluser]
You need this:
Code:
$config['uri_segment'] = 3;
And you need to take the $ID out.
Code:
$config['base_url']="http://domain.net/index.php/admin/partner/";

Pagination Class
#3

[eluser]sahanlak[/eluser]
Actually after page get viewed in the browser, the base url is like this. http://domain.net/index.php/admin/partner/1/

So with paginated
http://domain.net/index.php/admin/partner/1/2
#4

[eluser]sahanlak[/eluser]
It dsnt work, even if I set it correctly in $config['uri_segment'] its capturing the "1" in here
http://domain.net/index.php/admin/partner/1/2
but it has to be 2 the last number of the url.
#5

[eluser]Thomas Edwards[/eluser]
Like I said, you need to take the variable out of the base_url.

Code:
$this->load->library('pagination');

$config['base_url'] = "http://domain.net/index.php/admin/partner/";
$config['total_rows'] = 5;
$config['per_page'] = 2;
$config['num_links'] = 20;
$config['uri_segment'] = 3;
$config['cur_tag_open'] = '<b>';
$config['cur_tag_close'] = '</b>';

$this->pagination->initialize($config);
#6

[eluser]Thomas Edwards[/eluser]
Here’s a page: http://www.unionplus.co.uk/test/pages/

Here’s the code:
Code:
function pages()
{
$this->load->library('pagination');

$config['base_url'] = "/test/pages/";
$config['total_rows'] = 5;
$config['per_page'] = 2;
$config['num_links'] = 20;
$config['uri_segment'] = 3;

$this->pagination->initialize($config);

echo $this->pagination->create_links();
}
#7

[eluser]sahanlak[/eluser]
Yea that works, but I think the pagination get confuced with my url structure.

http://domain.net/index.php/admin/partner/1/2/

lets take number 1 and 2, number one is an input var that I pass to the partner method in admin controller; 2 is the number for pagination but for some reason even if I specify $config['uri_segment'] = 4; it keeps getting the 1 instead of 2. Hope it make sense.
#8

[eluser]sahanlak[/eluser]
For your example its not necessary to specify $config[‘uri_segment’] I think




Theme © iAndrew 2016 - Forum software by © MyBB