DOCUMENTATION

Search »

ft_get_page_nav

You may find yourself in a position where you have too much information to display on a single page and need to group them into pages, with the standard « 1 2 3 ... pagination links. This function is written for precisely this purpose. It works for showing pagination links for ANY lists of data.

It works by passing certain values - like the current page, the number of items per page and so on - to the pagination.tpl template (found in the theme folder root), which generates the pagination HTML / JS. As with all Smarty templates, if the pagination.tpl file isn't found in the theme's root, it will use the default pagination.tpl file in the /themes/default theme.

The function is called in your PHP, like so:

The function parameters are the following:

  1. the number of results in the total result set (required)
  2. the number of lines that appear per page (required)
  3. the current page number (required)
  4. any additional string you want to have passed along via the query string when the user clicks on one of the pagination links (optional)
  5. the key used to identify the page number, passed via the query string, e.g. index.php?page=5. The default is the string "page", but you can use whatever string you want (optional)
  6. the theme with which to render the HTML. This defaults to whatever theme the user is currently using, but in case you need a specific pagination.tpl file, you can specify the theme folder name (optional).

The "pagination" key has to be passed to the template via the ft_display_module_page function, like so:

Lastly, in your template just use the $pagination variable to display it:

And you're done!