Products' Pagination for Zen Cart v1.5.5 (and later)

Version 2.1.1 by lat9 and torvista

Copyright © 2010-2021 Vinos de Frutas Tropicales. All rights reserved.


Current Support Thread at Zen Cart Forums: https://www.zen-cart.com/forum/showthread.php?t=169227

Note: If you are using a Zen Cart version prior to 1.5.5, please use a previous 1.x.x version of Products' Pagination.

This plugin replaces the default previous/next navigation for your store’s product information pages:

  • document_general_info
  • document_product_info
  • product_free_shipping_info
  • product_info
  • product_music_info

and optionally (via admin configuration) the previous/next navigation for these other pages in your store:

  • account_history
  • advanced_search_result
  • featured_products
  • index (a.k.a. the product listing page)
  • product_reviews
  • products_all
  • products_new
  • reviews
  • specials

The updated display looks similar to this. Links to the first and last products in the category (or page groups for the "other" pages) are always displayed, and you control the maximum number of links to be shown. When you hover over a link on a product-information page, the name of the product associated with that link is displayed by the browser.

There are optional (default: false) controls in your admin's Configuration->Products Pagination that enable you to display a page-select drop-down where your visitors can choose which page of the display to go to next and/or an item-count drop-down where your visitors can choose how many items to view per display page. These controls appear only on the "Other pages to link".

Starting with v2.0.0, you also control whether the plugin's pagination links are active when your site is viewed by a mobile device. To enable that handling, the plugin makes use of the presumed pre-existing file /includes/classes/Mobile_Detect.php and is also aware of the layoutType handling provided by Zen Cart 1.5.5's responsive_classic template.

After you have copied the plugin's files to your store's file-system and logged into your admin-console, you will see a Configuration->Products Pagination selection. Within that selection, the following settings are available for you to customize the plugin's display:

  1. Products Pagination Version. Displays the plugin's current version and release date. (Added in v2.0.0)
  2. Enable Products Pagination?. Use this setting to enable (default) or disable the plugin's overall operation. (Added in v2.0.0)
  3. Enable Products Pagination (Mobile)?. Use this setting to enable or disable (default) the plugin's operation when viewed by a mobile/tablet device. When disabled, the pagination defaults to your template's "normal" formatting. (Added in v2.0.0)
  4. Products Pagination — Maximum Links. This value (default: 10) specifies the number of product links that are displayed without pagination; e.g. for the default value, if a category contains 10 or fewer products you'll get a next/previous display that contains selections for products 1 through 10 along with the Previous and Next links.
  5. Products Pagination — Intermediate Links. This value (default: 7) specifies the number of product links to show once pagination has "kicked in", i.e. if the number of products in the current category is greater than Maximum Links. For the default values, if the current category contains more than 10 products, you'll get a next/previous display that always contains the links for the first and last products and the Previous and Next links, as well as up to 7 product-specific links. An ellipsis (…) is displayed when there is a break in the product sequence.
  6. Enable product listing link?. This value (default: true) specifies whether (true) or not (false) to include a "View product listing" link on the same line as "Viewing product x of y".
  7. Enable links on other pages?. This value (default: true) specifies whether (true) or not (false) the "Other pages to link" will have the pagination links applied.
  8. Other pages to link. This value (default: account_history,advanced_search_result,featured_products,index,product_reviews,products_all,products_new,reviews,specials) contains a comma-separated list of "other" pages to which the pagination should be applied.
  9. Include page-select drop-down?. This value (default: false) specifies whether (true) or not (false) the "Other pages to link" will include a drop-down list to allow the customer to go to a specific page number.
  10. Include item-count drop-down?. This value (default: false) specifies whether (true) or not (false) the "Other pages to link" will include a drop-down list to allow the customer to choose the number of items displayed per page. The values are specified by the following field ("Item Counts").
  11. Item Counts. This value contains a comma-separated list that identifies the selections offered to the customer to allow them to choose the number of items displayed per page; the default value is "10,25,50,100,*", which identifies that the customer can choose one of 10, 25, 50, 100 or "All" items to be displayed. If enabled, the smallest numerical value in the list becomes the default minimum items displayed for all "Other" pages regardless of other admin settings.

This section identifies the procedure you'll use to install/update or remove the plugin for your Zen Cart.

There is one core-file overwrite in this plugin and there are template-overrides; you should always backup your cart's database and files prior to making any changes.

  1. Rename the YOUR_ADMIN folder to match your store's "secret" admin-folder name and the YOUR_TEMPLATE folders (two of them) to match your active template's name:
    1. /includes/modules/YOUR_TEMPLATE
    2. /includes/templates/YOUR_TEMPLATE
  2. Merge the plugin's core- and template-overrides with any pre-existing changes you've made to those files.
  3. Copy the plugin's files to your store's file-system:
    1. /includes/auto_loaders/config.pagination.php
    2. /includes/classes/pp_split_page_results.php
    3. /includes/classes/split_page_results.php (This is the zc157c version of the file, with 2 marked change-sections).
    4. /includes/classes/observers/class.products_pagination_observer.php
    5. /includes/extra_cart_actions/pagination_actions.php
    6. /includes/functions/extra_functions/products_pagination_functions.php
    7. /includes/languages/english/extra_definitions/products_pagination.php
    8. /includes/modules/pp_product_next_prev.php
    9. /includes/modules/YOUR_TEMPLATE/product_prev_next.php
    10. /includes/templates/template_default/templates/tpl_pp_products_next_previous.php
    11. /includes/templates/YOUR_TEMPLATE/css/stylesheet_prod_pagination.css
    12. /includes/templates/YOUR_TEMPLATE/templates/tpl_index_product_list.php
    13. /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_listing_display_order.php
    14. /includes/templates/YOUR_TEMPLATE/templates/tpl_products_next_previous.php
    15. /YOUR_ADMIN/includes/auto_loaders/config.products_pagination_admin.php
    16. /YOUR_ADMIN/includes/init_includes/init_product_pagination_admin.php
    17. /YOUR_ADMIN/includes/languages/english/extra_definitions/products_pagination.php
  4. Log into your Zen Cart admin. The plugin's auto-installer will run, creating the Configuration->Product Pagination settings.

The plugin's undergone some re-construction starting in v2.0.0, removing one of the core-file overwrites. If you're upgrading the plugin from v1.x.x, you'll need to check any changes made to /includes/init_includes/init_canonical.php (or, for some versions, /includes/init_includes/overrides/init_canonical.php.

If you've got that file in the "overrides" folder, it's probably safe to just remove that file and let your Zen Cart 1.5.4 or later's built-in processing take over. Otherwise, check your non-overrides file for a single addition by the "product_pagination" plugin and simply remove that code-block. Zen Cart observer-level processing handles that change in v2.0.0.

First, delete the files that were copied to your Zen Cart installation's file-system, restoring any core- and template- overrides that might have been necessary. Then use your admin's Tools->Run SQL Patches to run the file /docs/product_pagination/uninstall/product_pagination_uninstall.sql.

This section identifies the files added or modified for this plugin as well as the plugin's change history.

The plugin provides the following files in its distribution zip-file.

  1. /includes/auto_loaders/config.pagination.php (Added in v2.0.0)
  2. /includes/classes/pp_split_page_results.php (Added in v2.0.0)
  3. /includes/classes/split_page_results.php (This is the zc157 version of the file, with 2 marked change-sections).
  4. /includes/classes/observers/class.products_pagination_observer.php
  5. /includes/extra_cart_actions/pagination_actions.php
  6. /includes/functions/extra_functions/products_pagination_functions.php
  7. /includes/init_includes/init_canonical.php (Removed from distribution in v2.0.0)
  8. /includes/init_includes/init_pagination.php (Removed in v2.0.0)
  9. /includes/languages/english/extra_definitions/products_pagination.php
  10. /includes/modules/pp_product_next_prev.php
  11. /includes/modules/YOUR_TEMPLATE/product_listing.php (Removed in v2.0.0)
  12. /includes/modules/YOUR_TEMPLATE/product_prev_next.php
  13. /includes/templates/template_default/css/stylesheet_prod_pagination.css (Removed in v2.0.0)
  14. /includes/templates/template_default/templates/tpl_pp_products_next_previous.php (Added in v2.0.0)
  15. /includes/templates/YOUR_TEMPLATE/css/stylesheet_prod_pagination.css
  16. /includes/templates/YOUR_TEMPLATE/templates/tpl_index_product_list.php
  17. /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_listing_display_order.php
  18. /includes/templates/YOUR_TEMPLATE/templates/tpl_products_next_previous.php
  19. /YOUR_ADMIN/includes/auto_loaders/config.products_pagination_admin.php (Added in v2.0.0)
  20. /YOUR_ADMIN/includes/init_includes/init_product_pagination_admin.php (Added in v2.0.0)
  21. /YOUR_ADMIN/includes/languages/english/extra_definitions/products_pagination.php
  • v2.1.1, 2021-03-28 (torvista and lat9):
    • BUGFIX: Ensure unique form-name on multi-page listings with no top/bottom submit button.
    • BUGFIX: Correct MySQL error on account_history page for zc157 and later.
    • The following files were changed:
      1. /includes/classes/pp_split_page_results.php
      2. /includes/classes/split_pages_results.php (Now using the zc157c version as the change-basis)
      3. /YOUR_ADMIN/includes/init_includes/init_product_pagination_admin.php
  • v2.1.0, 2020-06-14 (torvista and lat9):
    • BUGFIX: Correct various PHP notices and processing errors in the plugin's observer-class.
    • BUGFIX: Use correct variable name in the plugin's split-page class.
    • BUGFIX: Move pagination HTML out of class-file to template.
    • BUGFIX: (Future proofing) Use zc157 files as the core/template change-basis; add check so that the plugin can be removed without additional changes.
    • CHANGE: zc157 interoperability, force the 'split_page_results.php' class to load that second time.
    • The following files were changed:
      1. /includes/auto_loaders/config.pagination.php
      2. /includes/classes/pp_split_page_results.php
      3. /includes/classes/split_page_results.php (Now using the zc157 version as the change-basis)
      4. /includes/classes/observers/class.products_pagination_observer.php
      5. /includes/languages/english/extra_definitions/products_pagination.php
      6. /includes/modules/YOUR_TEMPLATE/prod_prev_next.php
      7. /includes/templates/template_default/templates/tpl_pp_products_next_previous.php
      8. /includes/templates/YOUR_TEMPLATE/css/stylesheet_prod_pagination.css
      9. /includes/templates/YOUR_TEMPLATE/templates/tpl_index_product_list.php
      10. /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_listing_display_order.php
      11. /includes/templates/YOUR_TEMPLATE/templates/tpl_products_next_previous.php
      12. /YOUR_ADMIN/includes/init_includes/init_product_pagination_admin.php
  • v2.0.0, 2016-09-25:
    • Initial release as v2.0.0, for Zen Cart 1.5.5 and later, based on the like-named plugin's v1.5.0 file-set.
  • v1.5.0, 2015-03-26:
    • CHANGE: Include additional classes to enable styling for various display viewport sizes.
    • CHANGE: Move the init_canonical.php modification to the base init_includes directory, removing it from the init_includes/overrides directory — making it easier to upgrade.
    • The following files were changed/added/removed:
      • /includes/classes/split_page_results.php
      • /includes/init_includes/init_canonical.php
      • /includes/init_includes/overrides/init_canonical.php
      • /includes/templates/YOUR_TEMPLATE/templates/tpl_products_next_previous.php
  • v1.4.9, 2014-07-13:
    • Include updates for Zen Cart v1.5.2 and v1.5.3 compatibility, changed:
      1. /includes/init_includes/overrides/init_canonical.php
  • v1.4.8, 2014-05-30:
    • Verified Zen Cart v1.5.2 and v1.5.3 compatibility.
    • BUGFIX: Item count dropdown should contain "All" if the total items' count is less than the maximum Item Count value. Changed /includes/functions/extra_functions/products_pagination_functions.php.
  • v1.4.7, 2013-09-19:
    • BUGFIX: Modified BUGFIX #2 from v1.4.6, needed to check that the $count_key value was other than '*' rather than numeric; was causing incorrect results on the products' listing and advanced-search results pages. Changed /includes/classes/split_page_results.php.
  • v1.4.6, 2012-12-02:
    • BUGFIX: Changing item-count or page-count on advanced_search_results pages resulted in main page being displayed.
    • BUGFIX: Make sure that the count value is numeric before including DISTINCT in the MySQL count() directive.
    • The following files were changed/added:
      • /includes/classes/split_page_results.php
      • /includes/modules/YOUR_TEMPLATE/product_listing.php
  • v1.4.5, 2012-11-21:
    • BUGFIX: Problems on product_listing and advanced_search_results pages when using multiple-add-to-cart feature.
    • The following files were changed/added:
      • /includes/classes/split_page_results.php
      • /includes/extra_cart_actions/pagination_actions.php
      • /includes/init_includes/init_pagination.php
      • /includes/functions/extra_functions/products_pagination_functions.php
      • /includes/templates/YOUR_TEMPLATE/tpl_index_product_list.php
  • v1.4.4, 2012-11-12: Changed /includes/classes/split_page_results.php and /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_listing_display_order.php:
    • BUGFIX (yet again): Correct possible divide-by-0.
  • v1.4.3, 2012-10-20: Changed /includes/classes/split_page_results.php and /includes/functions/extra_functions/products_pagination_functions.php:
    • BUGFIX: Links are displayed when zero items are returned.
    • BUGFIX: Page-select dropdown is displayed even if only 1 page is active.
    • BUGFIX: Item-count dropdown is displayed even if there are fewer items than the minimum to display.
  • v1.4.2, 2012-10-03, Corrected possible divide-by-zero and sort/count reset issues on the advanced_search_result page. The following files have been changed:
    • /includes/classes/split_page_results.php
    • /includes/functions/extra_functions/products_pagination_functions.php
    • /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_listing_display_order.php
  • v1.4.1, 2012-09-23, Corrected problems where changing the sort-order or going next/previous would reset the items/page and resetting the items/page would reset the sort order. The following files have been changed/added:
    • /includes/classes/split_page_results.php
    • /includes/functions/extra_functions/products_pagination_functions.php
    • /includes/init_includes/overrides/init_canonical.php
    • /includes/templates/YOUR_TEMPLATE/templates/tpl_index_product_list.php
    • /includes/templates/YOUR_TEMPLATE/templates/tpl_modules_listing_display_order.php
  • v1.4.0, 2012-09-21:
    • Merged changes into v1.5.1 /includes/classes/split_page_results.php; the merged file supports v1.3.9 and v1.5.0 as well as v1.5.1.
    • Updated htmlentities call for PHP v5.4+
    • Corrected remaining HTML validation issue.
  • v1.3.0, 2012-09-02, Added support for drop-down page choice and/or user-selectable number of items-per-page. Note: New configuration switches in your admin enable these features — you will need to re-run the SQL install script on an upgrade.
  • v1.2.2, 2012-05-16, Corrected HTML validation errors (/includes/classes/split_page_results.php, /includes/functions/extra_functions/products_pagination_functions.php and /includes/templates/YOUR_TEMPLATE/templates/tpl_products_next_previous.php).
  • v1.2.1, 2012-03-20, Corrected install SQL scripts to remove unwanted back-quotes around column and table names.
  • v1.2.0, 2012-03-01, Added support for all pages currently used by the split pages' results. Consolidated the CSS into a single file.
  • v1.1.1, 2011-08-15, Updated 1.5.0+ install SQL to correct the problem described here.
  • v1.1.0, 2011-08-08, Updated install to support Zen Cart 1.5.0+ admin_pages.
  • v1.0.1, 2011-04-14, Added the product listing link feature; requires re-running the installation SQL if you want the link.
  • v1.0.0, 2010-11-30, Initial release.