Building a Page Controller with the jQuery Quick Pagination Plug-in
Welcome to the final installment of the series that introduces you to the jQuery Quick Pagination plug-in. Comprised of five parts, this series takes an in-depth look at the most useful features provided by this jQuery add-on and shows you how to use it either for splitting up hard-coded HTML elements, such as paragraphs and images in chunks of readable data, or for paginating sets of database records.
Building a Page Controller with the jQuery Quick Pagination Plug-in - Paginating user-related data (Page 4 of 4 )
As I said in the section you just read, to get this sample web application up and running, we need to paginate all of the user records. Fortunately, this can be done by amending the definition of the "header.htm" file in the following way:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<h1>Paginating database records with jQuery Quick Pagination plug-in</h1>
<h2>Header section</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse auctor commodo risus, et ultrices sapien vestibulum non. Maecenas scelerisque quam a nulla mattis tincidunt. Etiam massa libero, pharetra vel laoreet et, ultrices non leo. Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
Here, the Quick Pagination plug-in has been configured to display only one user record per page, but as you know from earlier examples, this behavior is completely customizable. Finally, there must exist an additional file that joins the individual header, content and footer sections in the same web page, so to fit this requirement I created one below, called "index.php." Look at it:
<?php
// include web page header
require_once 'header.htm';
// include web page content
require_once 'content.php';
// include web page footer
require_once 'footer.htm';
Mission accomplished. If you decide to run the above "index.php" file, assuming that you have a running web server with support for PHP already installed on your machine, then the following output should be displayed on the browser:
Don't you feel a little bit happier now? You should, since you learned how to use the Quick Pagination plug-in in a more realistic scenario, for paginating a set of database records. As usual, feel free to edit all of the code samples included in this tutorial, so you can tweak the plug-in's behavior and adapt it to suit your own requirements.
Final thoughts
It's hard to believe, but we've come to the end of this series. As you saw in the earlier tutorials, using the Quick Pagination plug-in either to paginate static HTML elements or a set of records pulled from a database is a simple process that can be tackled with minor hassles.
Therefore, if you're planning to include within your website a pagination mechanism that gives your visitors a more pleasant navigational experience without having to deal with a heavily-loaded JavaScript package or a server-side implementation, Quick Pagination is definitely an option worth considering.
See you in the next web design tutorial!
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.