OpenCart – Pagination

This will be a fun article because finally we will discuss what pagination is, the idea behind it, and how and where it is used in the Opencart Framework.

What is pagination?

Pagination is the process of dividing (content) into discrete pages, either electronic pages or printed pages. Today the latter are usually simply instances of the former that have been outputted to a printing device, such as a desktop printer or a modern printing press. For example, printed books and magazines are created first as electronic files (for example, PDF or QXD files) and then printed. Pagination encompasses rules and algorithms for deciding where page breaks will fall, which depends on semantic or cultural senses of which content belongs on the same page with related content and thus should not fall to another (e.g., widows and orphans). Pagination is sometimes a part of page layout, and other times is merely a process of arbitrary fragmentation.

In short, pagination allows for the results of data return from the Opencart server to be distributed in a more efficient manner so the customer does not see EVERYTHING AT ONCE. Here is a screen shot of pagination on the web. Notice on the bottom there is a choice to JUMP TO A DIFFERENT PAGE. This is pagination

pagination-3

In Opencart pagination is controlled by a number of variables. The files that control the pagination are:

System, control, model, and view

How does pagination work on Opencart?

Say your product search returns a result of 5 thousand items. Pagination will split all of these items page by page with a certain number of viewable items per page. That limit number is set up by an admin. During the Select query, the results will return back an array of data to the control file which then sends it to the HTML where the pagination can take place. The pagination is set up in the control file.

Open up category.php and look for this code:

$pagination = new Pagination();
			$pagination->total = $product_total;
			$pagination->page = $page;
			$pagination->limit = $limit;
			$pagination->text = $this->language->get('text_pagination');
			$pagination->url = $this->url->link('product/category', 'path=' . $this->request->get['path'] . $url . '&page={page}');

			$this->data['pagination'] = $pagination->render();

As you can see, the variables are filled here….and everything is echoed with a variable called $pagination.

Now, on the front end open up category.tpl and look for this code:

<div class="pagination"><?php echo $pagination; ?></div>

Looking for quality OpenCart Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , | Posted under OpenCart | RSS 2.0

Author Spotlight

Joe Stenhouse

Joe Stenhouse

I am a web application developer that specializes in PHP, JAVASCRIPT, MYSQL, HTML, and CSS. We manifest exciting potentials within the world wide web through means of innovation.

Leave a Reply

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


− 5 = 4

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