phpBB API Documentation
Class

phpbb\pagination

class pagination

Methods

__construct(template $template, user $user, helper $helper, dispatcher_interface $phpbb_dispatcher)

Constructor

null generate_template_pagination(string $base_url, string $block_var_name, string $start_name, int $num_items, int $per_page, int $start = 1, bool $reverse_count = false, bool $ignore_on_page = false)

Generate template rendered pagination Allows full control of rendering of pagination with the template

int get_on_page(int $per_page, int $start)

Get current page number

string on_page(int $num_items, int $per_page, int $start)

Return current page

int validate_start(int $start, int $per_page, int $num_items)

Get current page number

int reverse_start(int $start, int $limit, int $num_items)

Get new start when searching from the end

int reverse_limit(int $start, int $per_page, int $num_items)

Get new item limit when searching from the end

Details

at line 38
public __construct(template $template, user $user, helper $helper, dispatcher_interface $phpbb_dispatcher)

Constructor

Parameters

template $template
user $user
helper $helper
dispatcher_interface $phpbb_dispatcher

at line 137
public null generate_template_pagination(string $base_url, string $block_var_name, string $start_name, int $num_items, int $per_page, int $start = 1, bool $reverse_count = false, bool $ignore_on_page = false)

Generate template rendered pagination Allows full control of rendering of pagination with the template

Parameters

string $base_url is url prepended to all links generated within the function If you use page numbers inside your controller route, baseurl should contains a placeholder (%d) for the page. Also be sure to specify the pagination path information into the startname argument
string $block_var_name is the name assigned to the pagination data block within the template (example: )
string $start_name is the name of the parameter containing the first item of the given page (example: start=20) If you use page numbers inside your controller route, start name should be the string that should be removed for the first page (example: /page/%d)
int $num_items the total number of items, posts, etc., used to determine the number of pages to produce
int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce
int $start the item which should be considered currently active, used to determine the page we're on
bool $reverse_count determines whether we weight display of the list towards the start (false) or end (true) of the list
bool $ignore_on_page decides whether we enable an active (unlinked) item, used primarily for embedded lists

Return Value

null

at line 290
public int get_on_page(int $per_page, int $start)

Get current page number

Parameters

int $per_page the number of items, posts, etc. per page
int $start the item which should be considered currently active, used to determine the page we're on

Return Value

int Current page number

at line 303
public string on_page(int $num_items, int $per_page, int $start)

Return current page

Parameters

int $num_items the total number of items, posts, topics, etc.
int $per_page the number of items, posts, etc. per page
int $start the item which should be considered currently active, used to determine the page we're on

Return Value

string Descriptive pagination string (e.g. "page 1 of 10")

at line 317
public int validate_start(int $start, int $per_page, int $num_items)

Get current page number

Parameters

int $start the item which should be considered currently active, used to determine the page we're on
int $per_page the number of items, posts, etc. per page
int $num_items the total number of items, posts, topics, etc.

Return Value

int Current page number

at line 337
public int reverse_start(int $start, int $limit, int $num_items)

Get new start when searching from the end

If the user is trying to reach late pages, start searching from the end.

Parameters

int $start the item which should be considered currently active, used to determine the page we're on
int $limit the number of items, posts, etc. to display
int $num_items the total number of items, posts, topics, etc.

Return Value

int Current page number

at line 353
public int reverse_limit(int $start, int $per_page, int $num_items)

Get new item limit when searching from the end

If the user is trying to reach late pages, start searching from the end. In this case the items to display might be lower then the actual per_page setting.

Parameters

int $start the item which should be considered currently active, used to determine the page we're on
int $per_page the number of items, posts, etc. per page
int $num_items the total number of items, posts, topics, etc.

Return Value

int Current page number