Plugin Framework Function pagination()

protected final function pagination(
$paginationStyleSettingName, $currentPage, $pages, &$html, &$links = array()
)

Summary

This function allows you to easily create pagination for your Plugins.

Where You Can Use It

Can be used in methods called by plugins. From Zenario 7.0.0 onwards.

Description

This function allows you to use the pagination system that comes with Zenario to create a system of page numbers.

There are two advantages of doing this over using your own pagination logic:

  1. This function provides a few helpful features already implemented for you, such as options for different pagination logic and AJAX reloading if a Visitor has JavaScript enabled.
  2. If every Plugin in Zenario uses the same pagination system, Admins can set up websites that look consistent and behave consistently.

To use this function, you need a Plugin Setting of <type>pagination</type> defined in your Plugin's description.

You then need to provide the function with the name of this function, the current page number, and an array of all possible pages.

Parameters

$paginationStyleSettingName

The name of a Plugin Setting, where the named Plugin Setting must be a select list with values generated by the paginationOptions() Admin Function.

From 6.0.4 onwards you can also pass a value in directly. Acceptable values are class names and method names separated by two colons; for example:

tribiq_common_features::pagAll

tribiq_common_features::pagCloseWithNPIfNeeded

tribiq_common_features::pagCurrentWithFNPL or

tribiq_common_features::pagSelectList.

If nothing is entered or your requested class/method does not exist, tribiq_common_features::pagCloseWithNPIfNeeded will be used as a default.

$currentPage

The current page that you are displaying.

This should also appear as one of the keys in $pages.

$pages

An associative array of pages to request strings.

Please note that the keys and values are a different way around than our usual format for Lists of Values. In this case:

  •  
    • The keys of the array will be the text displayed to the Visitor.
    • The values of the array will be the request string which will be used to form a URL for the page links.

The CMS will not do any sorting; you should ensure that entries in this array are ordered in the order you wish them to appear on the page.

$html

The HTML for your pagination will be placed in this variable.

Return Value

No return value.

Example

<setting>
    <name>pagination_style</name>
    <label>Pagination style:</label>
    <type>pagination</type>
    <default_value>tribiq_cms_core::pagAllWithNPIfNeeded</default_value>
</setting>
$html = '';
$currentPage = ifNull((int) $this->get('page'), 1); $pages =
array( 1 => 'page=1', 2 => 'page=2', 3 => 'page=3');
$this->mergeFields['Pagination'] =
$this->pagination('pagination_style', $currentPage, $pages, &$html);

This simple example will create three pages, named 1, 2 and 3.