File tree Expand file tree Collapse file tree 2 files changed +35
-6
lines changed Expand file tree Collapse file tree 2 files changed +35
-6
lines changed Original file line number Diff line number Diff line change 1+ # Changelog
2+ The format is based on [ Keep a Changelog] ( http://keepachangelog.com/ ) and this project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
3+
4+ Exclamation symbols (:exclamation : ) note something of importance e.g. breaking changes. Click them to learn more.
5+
6+ ## [ Unreleased]
7+ ### Added
8+ - Initial version!
9+ ### Changed
10+ ### Deprecated
11+ ### Removed
12+ ### Fixed
13+ ### Security
14+
15+
16+ [ Unreleased ] : https://github.com/php-telegram-bot/inline-keyboard-pagination/compare/master...develop
Original file line number Diff line number Diff line change @@ -31,28 +31,41 @@ composer require php-telegram-bot/inline-keyboard-pagination:^1.0.0
3131$items = range(1, 100); // required.
3232$command = 'testCommand'; // optional. Default: pagination
3333$selected_page = 10; // optional. Default: 1
34+ $labels = [ // optional. Change button labels
35+ 'first' => '%d',
36+ 'previous' => 'previous %d',
37+ 'current' => null,
38+ 'next' => '%d next',
39+ 'last' => '%d',
40+ ];
3441```
3542
3643### How To Use
3744``` php
45+ // Define inline keyboard pagination.
3846$ikp = new InlineKeyboardPagination($items, $command);
3947$ikp->setMaxButtons(6);
40- $ikp->setWrapSelectedButton('< #VALUE# >' );
48+ $ikp->setLabels($labels );
4149
42- $pagination = $ikp->pagination($selected_page); //$ikp->setSelectedPage($selected_page);
50+ // Get pagination.
51+ $pagination = $ikp->getPagination($selected_page);
52+
53+ // or, in 2 steps:
54+ $ikp->setSelectedPage($selected_page);
55+ $pagination = $ikp->getPagination();
4356```
4457
4558### Result
4659``` php
47- if (!empty($paginate ['keyboard'])) {
48- $paginate ['keyboard'][0]['callback_data']; // testCommand?currentPage=10&nextPage=1
49- $paginate ['keyboard'][1]['callback_data']; // testCommand?currentPage=10&nextPage=9
60+ if (!empty($pagination ['keyboard'])) {
61+ $pagination ['keyboard'][0]['callback_data']; // testCommand?currentPage=10&nextPage=1
62+ $pagination ['keyboard'][1]['callback_data']; // testCommand?currentPage=10&nextPage=9
5063 ...
5164
5265 $response = [
5366 'reply_markup' => json_encode([
5467 'inline_keyboard' => [
55- $paginate ['keyboard'],
68+ $pagination ['keyboard'],
5669 ],
5770 ]),
5871 ];
You can’t perform that action at this time.
0 commit comments