Paginator

The paginator provides an easy method for creating paginated views from lists of objects such as those in the search page.

Settings

Simply have the following in portal.conf to change how many results are shown per page on a site basis:

[vidispine]
DEFAULT_RESULTS_SHOWN: 15

This can be overridden by a user setting stored in each User’s own profile.

Usage

The paginator can be loaded in to any template by providing the following tags. It will however expect the context below to work properly:

{% load paginator %}
{% paginator 4 %}

This will show 4 other pages either side of the current page. And will always show 8 results on the page if there are enough results to allow it.

There should be pagination context in the page.

Pagination context

The following is an example of context with values that the paginator requires:

1
2
3
4
5
6
'page': 2,
'pages': 33,
'has_previous': True,
'has_next': True,
'previous': 1,
'next': 3,

The paginator generates the following context for

‘querystring’: ‘A querystring with page=removed’ ‘page_numbers’: ‘A list of numbers for the paginator’

Template

The template for pagination is located in the template directory here:

includes/paginator.html

Not including the template will cause a server error on a production site, and it should be located under the portal_themes directory.

User

Each user has the number of results that they wish to be used stored against their UserProfile. This defaults when a user is first created to the DEFAULT_RESULTS_SHOWN setting.