A better solution would be to display the results on multiple pages, with a navigation system to go from one page to the other. Even if this can be realised with a combination of loops, such a solution would be relatively complex.
Therefore, in SPIP 1.9, a new feature has been introduced to easily paginate the results of a page.
Example
The basic version of the pagination system may be used by adding a tag and a criterion to your loops:
- the criterion
{pagination}will paginate the loop it is applied to, - the tag
#PAGINATION, used in one of the optional parts (“before” or “after”) of this loop will display the pagination links.
For a site with 90 published articles, this loop will display the ten most recent articles, and, at the top of the list, a list of links to the pages showing the 10 next elements, the 10 after that, etc. The resulting links would be similar to the following:
The index of the article slice to display will be provided in the URL with the parameter debut_page=x with the same name as the loop it refers to. (this parameter can be used in other loops with the usual criterion {debut_page,10}.)
Note: the total number of link displayed is limited; in that case, dots will be shown to go to the end of the pagination list or to come back to its begining.
Pagination’s Anchor
When using the #PAGINATION tag, an HTML anchor is introduced. This anchor will send the browser directly to the part of the page containing the pagination.
However, if the pagination links have to be placed under the list of articles (for example), then it would be better to place this anchor at the beginning of the list.
The #ANCRE_PAGINATION tag can be used to place the anchor somewhere else. This will just return the right HTML code for the anchor and tell the #PAGINATION tag not to display its anchor.
Total number of restults
In a loop with the {pagination} criterion, the tag
#TOTAL_BOUCLE will only display the number of elements displayed by the loop. This will then return 10 (by default) for all the pages except the last page that may contain less results.
To display the total number of elements that would have been displayed by the loop without {pagination}, you should use the tag #GRAND_TOTAL.
<B_pagination>
#ANCRE_PAGINATION
<BOUCLE_pagination (ARTICLES) {pagination}>
#TITRE <br />
</BOUCLE_pagination>
There is #GRAND_TOTAL articles, this page only displays #TOTAL_BOUCLE articles.
</B_pagination>will display: “There is 15570 articles, this page only displays 10 articles.”
Changing the {pagination} “step”
The default number of elements returned by a paginated loop is 10. This can easily be modified by adding a parameter to the criterion.
Thus
<BOUCLE_page (ARTICLES) {pagination 5}>
#TITRE <br />
</BOUCLE_page>will display the titles of the 5 articles after the debut_pageth article.
The value of the parameter can be a constant or any tag — in particular #ENV{xx} — which give the opportunity to do a fully on-request display.
Pagination and inclusions
If the paginated is in an included loop, you must add the parameter {self=#SELF} to the INCLUDE tag. This is required for the included template to be able to compute the parameter debut_xxx.
Styling the pagination
The list of pages constructed by the #PAGINATION contains a series of links with the current page having the class “.on”. You can therefore style this list by changing the styles of the a and .on selector.

SPIP 1.9.2