Welcome Guest, Not a member yet? Register   Sign In
Pagination with "real" pages
#1

[eluser]jlevine[/eluser]
I saw a couple threads about this from earlier in the month. The Pagination library uses offset values for pages instead of the actual page number. I've extended the core Pagination class and you can optionally use actual page numbers instead of offset values.

It is identical in use to the original Pagination class with the exception of the name of the library when loading it and an optional paramater for create_links().

Installing
Simply drop the MY_Pagination.php file attached to this post into your 'application/libraries' folder.

Usage Example
Code:
$this->load->library('my_pagination');

$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = '200';
$config['per_page'] = '20';

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

echo $this->my_pagination->create_links(false);

create_links()
This function now accepts $use_offsets as a parameter which can be TRUE or FALSE (TRUE by default). When set to FALSE, links use actual page numbers and offset values when set to TRUE.

I haven't tested this outside my own WAMP setup so any feedback would be appreciated.
#2

[eluser]Colin Williams[/eluser]
Contributions are welcome, but modifying core classes are not. Please read the guidlines for extending core classes in the user guide. Some solid documentation would help, too. CI even distributes a CSS/HTML template to match the look and feel of their user guide.
#3

[eluser]jlevine[/eluser]
[quote author="Colin Williams" date="1217213930"]Contributions are welcome, but modifying core classes are not. Please read the guidlines for extending core classes in the user guide. Some solid documentation would help, too. CI even distributes a CSS/HTML template to match the look and feel of their user guide.[/quote]

Sorry, I'm still new to CI, but thanks for the advice. I took my modified library down and am in the process of modifying it to be within the guidelines. I'll post it a little later today when it's finished.
#4

[eluser]fustaki[/eluser]
Maybe I noticed a little error using your MY_pagination library:
when rendering the link for the first page the URL is
Code:
http://example.com/index.php/test/page/1
instead of
Code:
http://example.com/index.php/test/page/
which smells like URL duplication for SE robots.
I just added the control on page 1
Code:
$n = ($i == 0 || $i == 1) ? '' : $i
and it seems to work..

Is there a 'trusted' version of your pagination extension within the guidelines?
anyway, good job!
bye ;-)




Theme © iAndrew 2016 - Forum software by © MyBB