Welcome Guest, Not a member yet? Register   Sign In
Problem with the pagination class
#1

[eluser]chzigkol[/eluser]
Hi,

I have the following bunch of code (check attached file) inside one of my controllers. In a nutshell this function is to show the messages of one user. It utilizes URI helper to take the username and calls the pagination class to split the message into several pages.

But I have a problem with the pagination links Sad

I can't find the bug in my code.

Anybody's help will be more that welcome.

Christos
#2

[eluser]Flemming[/eluser]
what is the problem? Can you be more specific?
#3

[eluser]chzigkol[/eluser]
ok. via the controller that I 've sent, a view is loaded which has this sample code

<?php echo $results; ?>
<?php echo $this->pagination->create_links(); ?>

and the produced HTML page has inappropriate links for the pagination. To be more specific the line echo $this->pagination->create_links() produce this html code

<strong>1</strong>&nbsp;

<a href="http://localhost/friendy/index.php/user/profile/chzigkol/5">2</a>&nbsp;

<a href="http://localhost/friendy/index.php/user/profile/chzigkol/10">3</a>&nbsp;

<a href="http://localhost/friendy/index.php/user/profile/chzigkol/5">&gt;</a>&nbsp;

take a look at the first and last line. There are errors in there. The last link should be ended with the number 15, not with 5.

I attached the two files, the view and the HTML. Maybe someone can find the problem

Thanks anyway

Christos
#4

[eluser]Flemming[/eluser]
the last item is the 'next' link surely - it just moves you on to the next page, not the last page.

to me it looks like it's working properly!
#5

[eluser]chzigkol[/eluser]
yeah you are right about the last link. it's the NEXT. However it is not working properly.

When i click on the links for the 2nd page (2) and for the 3rd page (3), the link for the first page (1) is not activated. It should have been activated anyway if I am not mistaken.

And there is no previous button when I am on the 2 or 3 page.

I was wondering if the two uri segments ($username and $offset) cause that problem to the pagination class.

Christos
#6

[eluser]Flemming[/eluser]
yep! sounds like CI hasn't guessed correctly which URI segment contains the pagination, so you can tell it:

Code:
$config['uri_segment'] = 4;
(I think your pagingation number is in uri segment 4?
#7

[eluser]chzigkol[/eluser]
yep! that was the error.

thanks a lot for your time.




Theme © iAndrew 2016 - Forum software by © MyBB