To use Pagination in Joomla

by Bhumi //Mar 26,2012 // 5 comments

To use Pagination in Joomla
Share This:Share on Facebook3Share on LinkedIn5Tweet about this on Twitter1Share on Google+2Share on Reddit0Buffer this pageDigg thisEmail this to someoneFlattr the authorShare on StumbleUpon0Share on TumblrPin on Pinterest1

Before some days, I was worked on one site and In this i need to add pagination on some pages in which only some contents were displaying at a time.so what i have done to add pagination in those pages in joomla,want to share with you so you get some idea to use default joomla pagination.

First of all, I have taken one variable $limit and define My Per page limit in it.

After then I have create offset for start limit

Let me explain about getVar function,getVar function is used to GET data from the request uri.

SYNTAX:

Uri_field: The field name you get value in it. i.e, index.php?limitstart = 0

Default_value: Default value that will be returned if the query name is not exist.

Value_type: HTTP request type(get or post or request) By deafult,its GET.

Variable_type: Data Type of the variable.

Next, I have write a database query to get number of rows and to retrieve all records

Basically,To get Pagination in you need to execute query two times.First query is to count total number of rows without LIMIT. Second query is exactly the same as the first, just without LIMIT and it will actually retrieve required data. It’s difficult to use two query when you have complex query that joins several tables.if you don’t want to execute complex query twice and don’t want to waste server resources,you can use SQL_CALC_FOUND_ROWS option of MySQL

SQL_CALC_FOUND_ROWS is a one feature of the MySql used to count total number of rows disregarding LIMIT clause in the SELECT statement

and Now,FOUND_ROWS() returns the total number of rows in the result set returned by that statement.

Note : SQL_CALC_FOUND_ROWS and FOUND_ROWS statements are much more faster

Next, SQL queries to get total rows

JPagination is the core class of Joomla used to add pagination to the Front-end and Back-end.JPagination has three parameters, first is the total records, second is offset(or start limit) and third parameter is rows per page.
Last,

Suggested Reading:

About Module Position in Joomla
Free shipping for specific Country in Virtuemart Joomla
Custom Query with Joomla

Hope above contents have helped you to use default joomla pagination in your site.

RELATED POST

To hide menu from logged in User in Joomla

Share This:0431010Here I come with quick article which provide tip or trick to hide menu from logged in users from Joomla. Joomla provides “Guest feature” READ MORE

Newly Approved Joomla Module

Share This:0400000 This Month I have not written much posts because of lot of work so haven’t got time to write article but Good news READ MORE

Pagination when getting posts from category in WordPress

Share This:0400000 One of my all-time favorite topic is WordPress. WordPress is lightweight blogging platform and here is new article in wordpress about to solve READ MORE

Sorting in Joomla Explained

Share This:2401000 Recently I am working on one project and i wanted to provide sorting save and edit option to the title in joomla website. READ MORE

Warning :Cannot find Joomla XML Setup file

Share This:1400000 Joomla is a one of the most popular open source CMS and i know you all the latest version of Joomla 3 has READ MORE

Feedback 5

  1. An outstanding share!I have just forwarded thhis onto a friend whho was doing a little homework on this.
    And he in fact bought me lunch simly because I found
    it for him… lol. So let me reword this…. Thank YOU for the meal!!
    But yeah, thanks for spending some time to talpk about this topic
    here on your wweb site.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">