Documentation
Kitchen Sink documentation of style: 'Delos' of skin: 'ILIAS'
Pagination
Description
- Purpose
- The pagination view control is used to display a section of a larger set of data. It allows the user to navigate through the pages by selecting the respective page and to change the amount of displayed entries.
- Composition
- Section/Offset are controlled by a "previous" and "next" glyph to navigate through the pages; shy-buttons are used for the distinct selection of a page. A second dropdown is used to select the amount of shown entries. When the total amount of records is unknown, a Numeric Input is used to directly enter the offset along with a button to apply the inputs.
- Effect
- Available ranges/pages are calculated by the given number of entries; when the number of entries is set to "unlimited" (PHP_MAX_INT), the section-control is not being displayed. When changing the amount of entries, pages are re-calculated and current offset is being set to the closest starting-point. If a previous/next chunk of data is not available, the according glyph is rendered unavailable. When there are more than a given amount of pages in total, first and last page will be available along with the pages surrounding the current one.
Example 1: Base
Array ( [0] => ILIAS\Data\Range Object ( [start:protected] => 30 [length:protected] => 10 ) )
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\ViewControl\Pagination; use ILIAS\UI\Implementation\Component\Input\ViewControl\Pagination; function base() { global $DIC; $f = $DIC->ui()->factory(); $r = $DIC->ui()->renderer(); $pagination = $f->input()->viewControl()->pagination() ->withTotalCount(932) ->withValue([Pagination::FNAME_OFFSET => 31, Pagination::FNAME_LIMIT => 10]) ; //view this in a ViewControlContainer with active request $vc_container = $f->input()->container()->viewControl()->standard([$pagination]) ->withRequest($DIC->http()->request()); return $r->render([ $f->legacy('<pre>' . print_r($vc_container->getData(), true) . '</pre>'), $f->divider()->horizontal(), $vc_container ]); }
Example 2: With limit options
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\ViewControl\Pagination; use ILIAS\UI\Implementation\Component\Input\ViewControl\Pagination; function with_limit_options() { global $DIC; $f = $DIC->ui()->factory(); $r = $DIC->ui()->renderer(); $dummy_signal = new \ILIAS\UI\Implementation\Component\Signal(''); $pagination_with_value = $f->input()->viewControl()->pagination() ->withOnChange($dummy_signal) ->withTotalCount(6932) ->withValue([Pagination::FNAME_OFFSET => 40, Pagination::FNAME_LIMIT => 10]); $pagination_with_options = $f->input()->viewControl()->pagination() ->withOnChange($dummy_signal) ->withTotalCount(6932) ->withLimitOptions([10,100,500,1000]); $pagination_without_total = $f->input()->viewControl()->pagination() ->withOnChange($dummy_signal) ->withValue([Pagination::FNAME_OFFSET => 42, Pagination::FNAME_LIMIT => 10]); return $r->render([ $pagination_with_value, $f->divider()->horizontal(), $pagination_with_options, $f->divider()->horizontal(), $pagination_without_total ]); }
Example 3: With one page
Array ( [0] => ILIAS\Data\Range Object ( [start:protected] => 0 [length:protected] => 10 ) )
<?php declare(strict_types=1); namespace ILIAS\UI\examples\Input\ViewControl\Pagination; use ILIAS\UI\Implementation\Component\Input\ViewControl\Pagination; function with_one_page() { global $DIC; $f = $DIC->ui()->factory(); $r = $DIC->ui()->renderer(); $pagination = $f->input()->viewControl()->pagination() ->withTotalCount(10) ->withValue([Pagination::FNAME_OFFSET => 0, Pagination::FNAME_LIMIT => 10]) ; //view this in a ViewControlContainer with active request $vc_container = $f->input()->container()->viewControl()->standard([$pagination]) ->withRequest($DIC->http()->request()); return $r->render([ $f->legacy('<pre>' . print_r($vc_container->getData(), true) . '</pre>'), $f->divider()->horizontal(), $vc_container ]); }
Relations
- Parents
- UIComponent
- Input
- View Control