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
31
31
$items = range(1, 100); // required.
32
32
$command = 'testCommand'; // optional. Default: pagination
33
33
$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
+ ];
34
41
```
35
42
36
43
### How To Use
37
44
``` php
45
+ // Define inline keyboard pagination.
38
46
$ikp = new InlineKeyboardPagination($items, $command);
39
47
$ikp->setMaxButtons(6);
40
- $ikp->setWrapSelectedButton('< #VALUE# >' );
48
+ $ikp->setLabels($labels );
41
49
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();
43
56
```
44
57
45
58
### Result
46
59
``` 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
50
63
...
51
64
52
65
$response = [
53
66
'reply_markup' => json_encode([
54
67
'inline_keyboard' => [
55
- $paginate ['keyboard'],
68
+ $pagination ['keyboard'],
56
69
],
57
70
]),
58
71
];
You can’t perform that action at this time.
0 commit comments