PageLite Documetation
###############################################################################
PageLite is a PHP Class that is used to generate pagination results on the fly
with little to no knowledge of how to use pagination.
This class requires only 2 parameters to run and only 4 lines of code here they are
include 'pagelite.php';
$pagi = new Page_Light('Number of Items', 'URL Link to use ours is index.php');
echo $pagi->build();
$start = $pagei->getStart();
Those three lines above will generate a nice pagination, that is fully functional.
Here is the config listing and their defaults.
/*
* Total Number of items that are being sorted by the SQL Query
*
* @access protected
*/
protected $_totalItems = null;
/*
* Url Link that will be used for pagination
*
* @access protected
*/
protected $_pagiUrl = null;
/*
* Total Number of items per page
*
* @access protected
*/
protected $_perPage = 10;
/*
* Total Number of lines to display half on each side of current page
*
* @access protected
*/
protected $_range = 5;
/*
* Use mod_rewrite style links
*
* @access protected
*/
protected $_rewrite = false;
/*
* Use page Jumping links ( 3, 7, 13, 25 )
*
* @access protected
*/
protected $_pageJump = true;
/*
* Total Number of jumps to perform per side
*
* @access protected
*/
protected $_jumpCount = 5;
/*
* Calculation number for a jump link ( currentPageLink * number = jumpLink)
*
* Lower numbers are recommended for foward jumping Anything over 1.25 will cause the links to jump
* at a very high rate
*
* @access protected
*/
protected $_jumpCalcFoward = 1.15;
/*
* Calculation number for a jump link ( currentPageLink * number = jumpLink)
*
* Lower numbers are not recommended for backwards jumping Anything under 1.25 will cause the links allmost to completely not jump
*
* @access protected
*/
protected $_jumpCalcBackward = 1.25;
/*
* GET Variable that the current page number is stored in
*
* @access protected
*/
protected $_pageIdentifer = 'page';
/*
* Automatically extract the page number based on the pageIdenitifer
*
* @access protected
*/
protected $_useAutoIdentifier = true;
/*
* Total Number of pages based on totalItems / perPage
*
* @access public
*/
public $totalPages = null;
Below are 3 different config arangements sorted by basic - technical - and advanced
#### Configuration - Basic
# Here are some examples of a basic configuration setup
// Customize the url identifier
// By default the idenitifer is page we are setting it to just ( p )
$pagi->setIdentifier('p');
// Now we are going to set the range for links
// We want 5 links per side the range is divided by 2
$pagi->setRange(10);
// Now we want to disable page jumping
$pagi->setPageJumping(false);
// Set the number of items you are displaying per page - default : 10
$pagi->setPerPage(15);
What this config will do is create a link set that generates output with
links that will point index.php?p=1,2,3 etc etc...
and will list the links starting with the current page in the middle with 5 page link to the left and 5 page link to the right in numerical order
#### Configuation - Techinal
# This is a more technical config that uses mod_rewrite, changes the jump counts for pages
// We are still using all the same config as before but expect for setting the page jumping to off
$pagi->setIdentifier('p');
$pagi->setRange(10);
// We are going to set the jumping links count total same as the range execpt the jump range is used as that number for both sides so a jump count of 10
// will producer 10 jumped links on each side
// Note that we did not have to turn on page jumping as we had to turn it off for the basic config as page jumping comes default as turned on
$pagi->setJumpCount(5);
// Turn on mod_rewrite URLS
// Note when this is done you must provide the url allready formatted for rewrite style urls and DO NOT add a trailing / as this is done automatically
// AutoIdentify will still function correctly as long as the identifier is correctly written in the mod_rewrite file
$pagi->setRewrite(true);
//
the following config will produce links that are set as
index/1, index/2 etc etc etc
#### Configuation - Advanced
# This is a more advanced configuration that adds style to the page turns of auto identify, change the jump count calculators and more
// I will skip the other configs and go into the advanced ones
// Stylesheets PageLite allways you to set the stylesheet for links and wrap each link in a piece of html code here is a full blown example the names
// are fairly self explainatory but il explain
$pageLiteAdv->setStyleArray(array(
'start' => '<div>', // start of the pagination
'end' => '</div>', // end of pagination
'first_start' => '<em>', // link to page 1 S
'first_end' => '</em>', // link to page 1 E
'current_start' => '<b>', // current linke start
'current_end' => '</b>', // current link end
'next_start' => '<em>', // next link start ( only one page forward)
'next_end' => '</em>', // next link end ( only one page forward)
'prev_start' => '<span style="text-decoration: underline;">', // prev link (only one page back)
'prev_end' => '</span>', // prev link (only one page back)
'link_start' => '', // Main link start ( most links )
'link_end' => '', // Main link end
'last_start' => '<em>', // Last page link start
'last_end' => '</em>',)); // Last page link end
));
// This can also be set statically by using
// Recommened if you want to set a stylearray to use everywhere but don't want to rewrite over and over again :)
Page_Lite::styleArray = array();
// The wrappers can be anything you want them to be from html tags to just plain'ol text
// Settings the jump calculators
// The forward jump calculator this works by taking the current link page and multiplying it by this ( keeping it below 1.25 and above 1.15 gives a good jump ratio)
$pagi->setJumpCalForward(1.19);
// The backward jump calculator this works by taking the current link page and dividing it by this ( keeping it above 1.25 and below 1.35 gives a good jump ratio)
$pagi->setJumpCalForward(1.34);
// Turn on Mod_Rewrite
$pagi->setRewrite(true);
Well thats a failry good explaination of Page Lite there is of course more features within but its more fun to explore and find them :)
Find any bugs email me at <hide@address.com>