Kiry Panel Page Numbers
https://github.com/jenstornell/kirby-panel-page-numbers
If you are developing a field or a plugin for the panel pagination can be needed.
Installation
You need to be a developer to understand how this class works.
Example: example-field.php
<?php
include __DIR__ . DS . 'page-numbers.php';
class YourField extends BaseField {
function input() {
$this->PageNumbers = new PageNumbers();
return $this->pageNumbers();
}
function pageNumbers() {
$children = $this->page->children()->sortBy('modified', 'desc');
return $this->PageNumbers->get($this->page, $children, 'revisions-page', 1);
}
}
###input
In this case the field input only return the pagination html, loaded from the pageNumbers
method.
###PageNumbers->get()
Here the magic happends. You need some arguments for it to work.
###page
The method needs the page object to know the url to the pagination.
###children
What pages do you want to list? Create a $children
object of your choice.
###name
This is the name of your $_GET
key.
###limit
This is the limit of how many pages there can be on each page.
Namespace
I really recommend to namespace the class.
Add something like this first in page-numbers.php
:
namespace JensTornell\MyField;
use tpl;
And something like this first in example-field.php
:
use JensTornell\MyField as MyField;
And when calling the class in example-field.php
, do it like this:
$this->PageNumbers = new MyField\PageNumbers();
Changelog
0.1
- Init release
Requirements
Kirby 2.3
License
MIT