Generate HTML pagination for accessibility.
Security package: https://github.com/rancoud/Security
composer require rancoud/pagination
$currentPage = 1;$countElements = 10;$countElementPerPage = 5;$p = new Pagination();$html = $p->generateHtml($currentPage, $countElements, $countElementPerPage);echo $html;
It will output
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Root represents <ul>
Item represents <li>
Link represents <a>
Parameter | Type | Default value | Description |
---|---|---|---|
configuration | array | [] | Parameters for changing pagination behavior |
generateHtml(currentPage: int, countElements: int, countElementPerPage: int): string
generateData(currentPage: int, countElements: int, countElementPerPage: int): array
countPages(countElements: int, countElementPerPage: int): int
locateItemInPage(countElementPerPage: int, indexItem: int): int
url (string) (example)
show_all_links (bool: false) (example)
use_previous (bool: false) (example)
always_use_previous (bool: false) (example)
use_next (bool: false) (example)
always_use_next (bool: false) (example)
use_dots (bool: false) (example)
count_pages_pair_limit (int: 0) (example)
count_pages_pair_adjacent (int: 2) (example)
text_previous (string: Previous page) (example)
text_next (string: Next page) (example)
text_dots (string: …) (example)
text_page (string: {{PAGE}}) (example)
aria_label_link (string: Goto page {{PAGE}}) (example)
aria_label_current_link (string: Current page, page {{PAGE}}) (example)
aria_label_nav (string: Pagination) (example)
aria_label_previous (string: Previous page) (example)
aria_label_next (string: Next page) (example)
thousands_separator (string) (example)
root_tag (string: ul) (example)
root_attrs (string) (example)
use_nav (bool: true) (example)
nav_attrs (string) (example)
item_tag (string: li) (example)
item_attrs (string) (example)
item_attrs_current (string) (example)
item_previous_attrs (string) (example)
item_previous_attrs_disabled (string) (example)
item_next_attrs (string) (example)
item_next_attrs_disabled (string) (example)
item_dots_attrs (string) (example)
link_tag (string: a) (example)
link_attrs (string) (example)
link_attrs_current (string) (example)
link_previous_attrs_disabled (string) (example)
link_next_attrs_disabled (string) (example)
dot_tag (string: span) (example)
dot_attrs (string) (example)
use_pretty_html (bool: true) (example)
html_tab_sequence (string: t) (example)
html_initial_indentation (int: 0) (example)
esc_attr (bool: true) (example)
esc_html (bool: true) (example)
charset (string: UTF-8) (example)
You have to sanitize by yourself thoses parameters:
nav_attrs
root_attrs
item_attrs
item_attrs_current
item_previous_attrs
item_previous_attrs_disabled
item_next_attrs
item_next_attrs_disabled
item_dots_attrs
link_attrs
link_attrs_current
link_previous_attrs_disabled
link_next_attrs_disabled
dot_attrs
html_tab_sequence
Page append at the end
$conf = ['url' => 'https://example.com/news/page/'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="https://example.com/news/page/2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['url' => 'https://example.com/news/page/{{PAGE}}/?date=desc'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="https://example.com/news/page/2/?date=desc" aria-label="Page 2">2</a></li></ul></nav>
After page replace with {{PAGE}} pattern
$conf = ['url' => '{{PAGE}}?date=desc'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2?date=desc" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / Url
$conf = ['show_all_links' => true];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li><a href="4" aria-label="Page 4">4</a></li><li><a href="5" aria-label="Page 5">5</a></li><li><a href="6" aria-label="Page 6">6</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
$conf = ['use_previous' => true];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Previous page">Previous page</a></li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
Previous has aria-disabled=true
on link tag if there is no previous page
$conf = ['always_use_previous' => true];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Previous page" aria-disabled="true">Previous page</a></li><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
$conf = ['use_next' => true];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="2" aria-label="Next page">Next page</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
Next has aria-disabled=true
on link tag if there is no next page
$conf = ['always_use_next' => true];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li><li><a href="#" aria-label="Next page" aria-disabled="true">Next page</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
$conf = ['use_dots' => true];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"><span>…</span></li></ul></nav>
⏫ Configuration Parameters / Behavior
$conf = ['count_pages_pair_limit' => 1];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="3" aria-label="Page 3">3</a></li><li><a href="4" aria-label="Page 4">4</a></li><li><a href="#" aria-label="Page 5" aria-current="page">5</a></li><li><a href="6" aria-label="Page 6">6</a></li><li><a href="7" aria-label="Page 7">7</a></li><li><a href="60" aria-label="Page 60">60</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
$conf = ['count_pages_pair_adjacent' => 1];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="Pagination"><ul><li><a href="4" aria-label="Page 4">4</a></li><li><a href="#" aria-label="Page 5" aria-current="page">5</a></li><li><a href="6" aria-label="Page 6">6</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
count_pages_pair_limit 0 + count_pages_pair_adjacent 0
$conf = ['count_pages_pair_limit' => 0,'count_pages_pair_adjacent' => 0];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 5" aria-current="page">5</a></li></ul></nav>
count_pages_pair_limit 2 + count_pages_pair_adjacent 2
$conf = ['count_pages_pair_limit' => 2,'count_pages_pair_adjacent' => 2];echo (new Pagination($conf))->generateHtml(5, 300, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li><a href="4" aria-label="Page 4">4</a></li><li><a href="#" aria-label="Page 5" aria-current="page">5</a></li><li><a href="6" aria-label="Page 6">6</a></li><li><a href="7" aria-label="Page 7">7</a></li><li><a href="59" aria-label="Page 59">59</a></li><li><a href="60" aria-label="Page 60">60</a></li></ul></nav>
⏫ Configuration Parameters / Behavior
$conf = ['use_previous' => true,'text_previous' => 'prev'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Previous page">prev</a></li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['use_next' => true,'text_next' => 'next'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="2" aria-label="Next page">next</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['use_dots' => true,'text_dots' => 'dots'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"><span>dots</span></li></ul></nav>
⏫ Configuration Parameters / Labels
Page append at the end
$conf = ['text_page' => 'yolo'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">yolo 1</a></li><li><a href="2" aria-label="Page 2">yolo 2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['text_page' => 'yo {{PAGE}} lo'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">yo 1 lo</a></li><li><a href="2" aria-label="Page 2">yo 2 lo</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['aria_label_link' => 'aria label link'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="aria label link">2</a></li></ul></nav>
With {{PAGE}} pattern
$conf = ['aria_label_link' => 'aria label link {{PAGE}}'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="aria label link 2">2</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['aria_label_current_link' => 'aria label current link'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="aria label current link" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['aria_label_current_link' => 'aria label current link {{PAGE}}'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="aria label current link 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['aria_label_nav' => 'aria label nav'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="aria label nav"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['use_previous' => true,'aria_label_previous' => 'prev'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="prev">Previous page</a></li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['use_next' => true,'aria_label_next' => 'next'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="2" aria-label="next">Next page</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['thousands_separator' => ';','count_pages_pair_limit' => 1];echo (new Pagination($conf))->generateHtml(1, 1000, 1);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li><a href="1000" aria-label="Page 1000">1;000</a></li></ul></nav>
⏫ Configuration Parameters / Labels
$conf = ['root_tag' => 'root'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><root><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></root></nav>
⏫ Configuration Parameters / HTML markup / Root
$conf = ['root_attrs' => 'data-root="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul data-root="attrs"><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Root
$conf = ['use_nav' => false];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul>
⏫ Configuration Parameters / HTML markup / Root
$conf = ['nav_attrs' => 'data-item="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination" data-item="attrs"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Root
$conf = ['item_tag' => 'item'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><item><a href="#" aria-label="Page 1" aria-current="page">1</a></item><item><a href="2" aria-label="Page 2">2</a></item></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['item_attrs' => 'data-item="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li data-item="attrs"><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['item_attrs' => 'data-item="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li data-item="attrs 2"><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['item_attrs_current' => 'data-item-current="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-current="attrs"><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['item_attrs_current' => 'data-item-current="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-current="attrs 1"><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['use_previous' => true,'item_previous_attrs' => 'data-item-previous="attrs"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-previous="attrs"><a href="1" aria-label="Previous page">Previous page</a></li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['use_previous' => true,'item_previous_attrs' => 'data-item-previous="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-previous="attrs 1"><a href="1" aria-label="Previous page">Previous page</a></li><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['always_use_previous' => true,'item_previous_attrs_disabled' => 'data-item-previous-disabled="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-previous-disabled="attrs"><a href="#" aria-label="Previous page" aria-disabled="true">Previous page</a></li><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['always_use_previous' => true,'item_previous_attrs_disabled' => 'data-item-previous-disabled="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li data-item-previous-disabled="attrs 0"><a href="#" aria-label="Previous page" aria-disabled="true">Previous page</a></li><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['use_next' => true,'item_next_attrs' => 'data-item-next="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li data-item-next="attrs"><a href="2" aria-label="Next page">Next page</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['use_next' => true,'item_next_attrs' => 'data-item-next="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li data-item-next="attrs 2"><a href="2" aria-label="Next page">Next page</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['always_use_next' => true,'item_next_attrs_disabled' => 'data-item-next-disabled="attrs"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li><li data-item-next-disabled="attrs"><a href="#" aria-label="Next page" aria-disabled="true">Next page</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['always_use_next' => true,'item_next_attrs_disabled' => 'data-item-next-disabled="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li><li data-item-next-disabled="attrs 2"><a href="#" aria-label="Next page" aria-disabled="true">Next page</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['use_dots' => true,'item_dots_attrs' => 'data-item-dots="attrs"'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li data-item-dots="attrs" aria-hidden="true"><span>…</span></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Item
$conf = ['link_tag' => 'link'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><link href="#" aria-label="Page 1" aria-current="page">1</link></li><li><link href="2" aria-label="Page 2">2</link></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['link_attrs' => 'data-link="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a data-link="attrs" href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['link_attrs' => 'data-link="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a data-link="attrs 2" href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['link_attrs_current' => 'data-link-current="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a data-link-current="attrs" href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['link_attrs_current' => 'data-link-current="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a data-link-current="attrs 1" href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['always_use_previous' => true,'link_previous_attrs_disabled' => 'data-item-next-disabled="attrs"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a data-item-next-disabled="attrs" href="#" aria-label="Previous page" aria-disabled="true">Previous page</a></li><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['always_use_previous' => true,'link_previous_attrs_disabled' => 'data-item-next-disabled="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a data-item-next-disabled="attrs 0" href="#" aria-label="Previous page" aria-disabled="true">Previous page</a></li><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['always_use_next' => true,'link_next_attrs_disabled' => 'data-item-next-disabled="attrs"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li><li><a data-item-next-disabled="attrs" href="#" aria-label="Next page" aria-disabled="true">Next page</a></li></ul></nav>
Page replace with {{PAGE}} pattern
$conf = ['always_use_next' => true,'link_next_attrs_disabled' => 'data-item-next-disabled="attrs {{PAGE}}"'];echo (new Pagination($conf))->generateHtml(2, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="1" aria-label="Page 1">1</a></li><li><a href="#" aria-label="Page 2" aria-current="page">2</a></li><li><a data-item-next-disabled="attrs 2" href="#" aria-label="Next page" aria-disabled="true">Next page</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['use_dots' => true,'dot_tag' => 'p'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"><p>…</p></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['use_dots' => true,'dot_attrs' => 'data-dot="attrs"'];echo (new Pagination($conf))->generateHtml(1, 30, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li><li><a href="3" aria-label="Page 3">3</a></li><li aria-hidden="true"><span data-dot="attrs">…</span></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Link
$conf = ['use_pretty_html' => false];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Indentation
$conf = ['html_tab_sequence' => ''];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Indentation
$conf = ['html_initial_indentation' => 1];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Indentation
$conf = ['esc_attr' => false];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Security
$conf = ['esc_html' => false,'text_page' => '<em>{{PAGE}}</em>'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page"><em>1</em></a></li><li><a href="2" aria-label="Page 2"><em>2</em></a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Security
$conf = ['charset' => 'EUC-JP'];echo (new Pagination($conf))->generateHtml(1, 10, 5);
<nav aria-label="Pagination"><ul><li><a href="#" aria-label="Page 1" aria-current="page">1</a></li><li><a href="2" aria-label="Page 2">2</a></li></ul></nav>
⏫ Configuration Parameters / HTML markup / Security
$conf = ['always_use_previous' => true,'always_use_next' => true,'use_dots' => true, ]var_dump(new Pagination($conf))->generateData(1, 3000, 5);array (size=3) 'previous' => object(RancoudPaginationItem)[2] public 'ariaLabel' => string 'Previous page' (length=18) public 'href' => string '#' (length=6) public 'itemAttrs' => string '' (length=0) public 'linkAttrs' => string '' (length=0) public 'text' => string 'Previous page' (length=13) public 'isCurrent' => boolean false public 'isDots' => boolean false public 'isDisabled' => boolean true public 'page' => int 0 'links' => array (size=4) 0 => object(RancoudPaginationItem)[4] public 'ariaLabel' => string 'Page 1' (length=11) public 'href' => string '#' (length=6) public 'itemAttrs' => string '' (length=0) public 'linkAttrs' => string '' (length=0) public 'text' => string '1' (length=1) public 'isCurrent' => boolean true public 'isDots' => boolean false public 'isDisabled' => boolean false public 'page' => int 1 1 => object(RancoudPaginationItem)[5] public 'ariaLabel' => string 'Page 2' (length=11) public 'href' => string '2' (length=1) public 'itemAttrs' => string '' (length=0) public 'linkAttrs' => string '' (length=0) public 'text' => string '2' (length=1) public 'isCurrent' => boolean false public 'isDots' => boolean false public 'isDisabled' => boolean false public 'page' => int 2 2 => object(RancoudPaginationItem)[6] public 'ariaLabel' => string 'Page 3' (length=11) public 'href' => string '3' (length=1) public 'itemAttrs' => string '' (length=0) public 'linkAttrs' => string '' (length=0) public 'text' => string '3' (length=1) public 'isCurrent' => boolean false public 'isDots' => boolean false public 'isDisabled' => boolean false public 'page' => int 3 3 => object(RancoudPaginationItem)[7] public 'ariaLabel' => string 'Page 4' (length=11) public 'href' => string '4' (length=1) public 'itemAttrs' => string '' (length=0) public 'linkAttrs' => string '' (length=0) public 'text' => string '…' (length=3) public 'isCurrent' => boolean false public 'isDots' => boolean true public 'isDisabled' => boolean false public 'page' => int 4 'next' => object(RancoudPaginationItem)[8] public 'ariaLabel' => string 'Next page' (length=14) public 'href' => string '2' (length=1) public 'itemAttrs' => string '' (length=0) public 'linkAttrs' => string '' (length=0) public 'text' => string 'Next page' (length=9) public 'isCurrent' => boolean false public 'isDots' => boolean false public 'isDisabled' => boolean false public 'page' => int 2
composer ci
for php-cs-fixer and phpunit and coveragecomposer lint
for php-cs-fixercomposer test
for phpunit and coverage