PHP Classes


Recommend this page to a friend!
  Classes of Miraz Mac  >  PHP Pagination Links  >  >  Download  
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Pagination Links
Display links to browse pages of entry listings
Author: By
Last change:
Date: 5 years ago
Size: 2,017 bytes


Class file image Download


Yet another PHP class to generate pagination links in PHP.

Looking for a quick way to generate pagination links? Say no more! Though the code is well commented and there is a full example inside examples directory I would still write some basic documentation here.

Install via Composer <3

composer require mirazmac/pagination-links

PaginationLinks Options

Pagination links has these options to control its appearance/behavior.

$OPTIONS = array(
	 * The base URL
	 * %_PAGE% - Prints the page number
	 * %_QUERY% - Appends the current GET Query
	'url' => '?page=%_PAGE%&foo=bar%_QUERY%',

	/ Toggle the `First & Last` Links */
	'show_extra' => true,

	/ Toggle numeric pagination ( 1 2 3 4...8 ) */
	'show_numeric' => true,

	 * The GET key to skip from appending in %_QUERY%
	 * append_get_queries must be set to true if you want to use this
	'get_key_to_skip' => array('foo', 'cool', 'bar'),

Getting Started

To use PaginationLinks you must include it it your project.

require_once 'src/PaginationLinks.php';
use mirazmac\PaginationLinks;
$pagination = New PaginationLinks();
// Optionally, You can pass an array of options in constructor
$pagination = New PaginationLinks($OPTIONS);

Build the Pages

This is a MUST do to build the pages after constructing the class. Just like this:

 * Build the Pagination links
 * @param  integer  $total        Number of total items
 * @param  integer  $current_page Number of current page
 * @param  integer $per_page     Number of Items per page (defaults to 10)
 * @return boolean               Returns always true.
$pagination->buildPages($total, $current_page, $per_page);

Show the PaginationLinks

After building the pages, you can show it just like this ( I ain't gonna say this anymore -_- )

// Voila!!
echo $pagination->getPages();

No more docs!

Please read the code, explore the example! Sorry for my bad English -_-

For more information send a message to info at phpclasses dot org.