Jump to content

IPB4 Pagination?


szalik.dev

Recommended Posts

Pagination is generally easy - for the most part it is handled in the templates.

{template="pagination" group="global" app="core" location="global" params="$table->baseUrl, $table->pages, $table->page, $table->limit, TRUE, $table->getPaginationKey()"}

The parameter list is

  • The base URL
  • Total number of pages
  • The current page
  • The number of items per-page
  • TRUE or FALSE whether to support AJAX page loading
  • The page parameter (i.e. ?page=3) in the URL
  • TRUE or FALSE whether to use simple pagination (usually leave this FALSE)

On the backend you need to figure out the page number coming in and then multiple it by the number of items per page to determine your SQL offsets. If there is no page number (or it is less than 1...keep in mind users can play with URLs) then use 1. If you find that the offset you create by multiplying the page number times the number of items per page is more than the number of items you have, you may wish to reset to the last page (again, remember that users can play with URLs and send ?page=10000000 just because they want to see if they can break your application).

Now, if you use \IPS\Helpers\Table (there are subclasses here you should look at, you probably want \IPS\Helpers\Table\Db) most of this is taken care of for you.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...