1
0
Fork 0

allow pagination

This commit is contained in:
Lukas Winkler 2017-09-25 11:07:32 +02:00
parent eb3fc1c120
commit 03b15b61fd
3 changed files with 9 additions and 2 deletions

View file

@ -44,3 +44,9 @@ define('FORBIDDEN_EXTENSIONS', ['swf', 'js', 'html', 'htm']);
*/ */
define('PIWIK_URL', false); define('PIWIK_URL', false);
define('PIWIK_ID', false); define('PIWIK_ID', false);
/**
* Number of pages to show before and after the current page in the pagination. e.g. default (5) on page 37:
* < 1 ... 32 33 34 35 36 *37** 38 39 40 40 42 ... 115 >
*/
define("PAGINATION_PADDING", 5);

View file

@ -45,7 +45,8 @@ class Twig
} }
private static function getPaginationFunction() { private static function getPaginationFunction() {
return new \Twig_Function('paginationFunction', function ($numPages, $page, $padding = 2) { return new \Twig_Function('paginationFunction', function ($numPages, $page) {
$padding = PAGINATION_PADDING;
$pages = [1]; $pages = [1];
$i = 2; $i = 2;
while ($i <= $numPages) { while ($i <= $numPages) {

View file

@ -16,7 +16,7 @@
{% macro pagination(num_pages, page) %} {% macro pagination(num_pages, page) %}
{% import _self as m %} {% import _self as m %}
{% set pagearray = paginationFunction(num_pages, page,5) %} {% set pagearray = paginationFunction(num_pages, page) %}
<!-- License of svg icons - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) --> <!-- License of svg icons - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) -->
<ul class="pagination"> <ul class="pagination">
{% if page > 1 %} {% if page > 1 %}