Home arrow JavaScript arrow Page 4 - Building a Page Controller with the jQuery Quick Pagination Plug-in
JAVASCRIPT

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.

Author Info:
By: Alejandro Gervasio
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
December 31, 2009
TABLE OF CONTENTS:
  1. · Building a Page Controller with the jQuery Quick Pagination Plug-in
  2. · Review: web application source code so far
  3. · Building a simple page controller in PHP
  4. · Paginating user-related data

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
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">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Paginating database records with jQuery Quick Pagination plug-in</title>

<script src="jquery-1.3.2.min.js" type="text/javascript"></script>

<script src="jquery.quickpaginate.js" type="text/javascript"></script>

<script type="text/javascript">

$(document).ready(function(){

$("#users div").quickpaginate({ perpage: 1, showcounter: true });

});

</script>

<style type="text/css">

body {

padding: 0;

margin: 0;

background: #fff;

font: 1em Arial, Helvetica, sans-serif;

color: #000;

}

#wrapper {

width: 960px;

margin: 0 auto;

background: #f0f0f0;

}

#header, #content, #footer {

padding: 30px;

}

#users {

padding: 30px;

background: #c0c0ff;

border: 1px solid #000;

}

</style>

</head>

<body>

<div id="wrapper">

<div id="header">

<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.

blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials