Welcome Guest, Not a member yet? Register   Sign In
Codeigniter pagination
#1

[eluser]RomanN[/eluser]
Hello.
My name is Roman.

I've a bit issue with codeigniter pagination class. When I'm using pagination in method that has only one parameter all works well.
But when I try to use it in a method with 2 parameters, where I need to specify 'uri_segment' pagination doesn't work well. After switching the page the data is changing but the links left the same as on previous page.

Can somebody help me with it?

Thanks!
Roman
#2

[eluser]praveens[/eluser]
hi can u paste your code
#3

[eluser]RomanN[/eluser]
Here is the part of code where I configure pagination:

Code:
$pagination_config['base_url'] = base_url().'index.php/quotes/showchapter/'.$chapter_id.'/';
$pagination_config['total_rows'] = $query->num_rows();
$pagination_config['per_page'] = QUOTES_PER_PAGE;
$pagination_config['num_links'] = 2;
$pagination_config['first_link'] = 'Start';
$pagination_config['last_link'] = 'End';
$pagination_config['next_link'] = ' > ';
$pagination_config['prev_link'] = ' < ';
$pagination_config['uri_segment'] = 2;
$this->pagination->initialize($pagination_config);
#4

[eluser]Flemming[/eluser]
I think you need to change
Code:
$pagination_config['uri_segment'] = 2;

You should be passing the pagination start number in the uri (is that what $chapter_id is?)
#5

[eluser]RomanN[/eluser]
No, $chapter_id isn't pagination variable. It's first method parameter and the pagination is the second one.
#6

[eluser]Flemming[/eluser]
In that case I think your
Code:
$pagination_config['uri_segment']
should be set to = 5

index.php =1
quotes = 2
showchapter = 3
chapter_id = 4
pagination = 5 (and you will need to pass this value to your db query to get the next set of results

Does that help?
#7

[eluser]RomanN[/eluser]
Thanks for reply, but not, it didn't help.

The same problem. After switching the page the data from db is updated (so pagination variable is correctly passed to a query), but pagination links left the same (look like I'm on 1 page).

It's a bit strange, because all works well in the situation with one method parameter, where no need to use 'uri_segment'.
#8

[eluser]Flemming[/eluser]
I'm 90% certain your problem lies with
Code:
$pagination_config['uri_segment'] = 2;
what is the full url of your page?
#9

[eluser]RomanN[/eluser]
[quote author="flemming" date="1256662228"]I'm 90% certain your problem lies with
Code:
$pagination_config['uri_segment'] = 2;
what is the full url of your page?[/quote]
Hope you're right.

The full path to my page is:
http://localhost/quotes/index.php/quotes...hapter/1/0

Where 1 - is chapter_id
and 0 - pagination variable
#10

[eluser]Flemming[/eluser]
Code:
$pagination_config['uri_segment'] = 6;

should fix it then! The pagination class *tries* to figure out which segement of the URI to use - sometimes it gets it wrong (it's probably using seg(5) because it contains a number) so you have to help it and tell it which segement is the right one to use!




Theme © iAndrew 2016 - Forum software by © MyBB