2017 © Pedro Peláez
 

library simple-pagination

A simple PHP pagination class working perfectly with all PHP projects

image

duykpro/simple-pagination

A simple PHP pagination class working perfectly with all PHP projects

  • Wednesday, March 22, 2017
  • by duykpro
  • Repository
  • 1 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Description

This is a Simple PHP pagination class working perfectly with all PHP projects, (*1)

Example of usage:

``` 'http://example.com/', 'uri_path' => '', // URI path (IE: controller/action/id), leave none for auto detection 'num_links' => 3, // Number of page links to show 'total_items' => 0, // Total items (ie: count($allRowsFromDatabase)) 'items_per_page' => 20, // Number of items per page 'get_query' => false, // (Default is false). Using query string or uri segment? See example below 'uri_segment_position' => 0, // (if "get_query" is "false") Count from 0, Exp: controller/action/id/{page} => 3 // (Optional) Page prefix and suffix (Exp: ?page=prefix{page}suffix) 'prefix' => '', 'suffix' => '', // (Optional) Link text 'first_link_text' => 'First', 'last_link_text' => 'Last', 'previous_link_text' => 'Previous', 'next_link_text' => 'Next' ); $pagination = new DuyK\Pagination($config); // Pagination data $paginationData = $pagination->generate(); // You can use var_dump($paginationData) to see the structure ``` HTML: ``` , (*2)


Example of using "get_query" => true ----------------------------------- If "get_query" is "true", meaning that we'll use a HTTP GET param as your current page ```<?php // If setting "get_query" => true $config = array( ...YOUR OTHER CONFIG... 'uri_path' => 'blog/something', 'get_query' => 'page', );

Result will be like this:, (*3)

If URL is: http://example.com/blog
Then pagination links will be:
http://example.com/blog?page=1
http://example.com/blog?page=2
http://example.com/blog?page=3
http://example.com/blog?page=4
...

Don't worry if your URL contains other GET param. For example if your URL is: http://example.com/blog?param1=test&param2=something
Then pagination links will be:
http://example.com/blog?param1=test&param2=something&page=1
http://example.com/blog?param1=test&param2=something&page=2
http://example.com/blog?param1=test&param2=something&page=3
http://example.com/blog?param1=test&param2=something&page=4
...

Example of using "get_query" => false

If "get_query" is false, meaning that we'll use a segment in your URI path to detect your current page ```<?php, (*4)

// If setting "get_query" => false // Full URL in this example: http://example.com/blog/category-name/1/something/else (1 is the current page) // Also available if the "page" is the last segment like: http://example.com/blog/category-name/{page} // If {page} is null, then its value will be treated as "1" $config = array( ...YOUR OTHER CONFIG... 'get_query' => false, 'uri_segment_position' => 2, // Will be 2 in this case because [0 => 'blog', 1 => 'category-name', 2 => {page-number-here}...] );, (*5)


Result will be like this

http://example.com/blog/category-name/1/something/else http://example.com/blog/category-name/2/something/else http://example.com/blog/category-name/3/something/else http://example.com/blog/category-name/4/something/else ... ```, (*6)

The Versions

22/03 2017

dev-master

9999999-dev http://duyk.info

A simple PHP pagination class working perfectly with all PHP projects

  Sources   Download

The Requires

 

by Doan Khanh

22/03 2017

1.1

1.1.0.0 http://duyk.info

A simple PHP pagination class working perfectly with all PHP projects

  Sources   Download

The Requires

 

by Doan Khanh

25/08 2016

1.0

1.0.0.0 http://duyk.info

A simple PHP pagination class working perfectly with all PHP projects

  Sources   Download

The Requires

 

by Doan Khanh