{"id":15030226,"url":"https://github.com/php-telegram-bot/inline-keyboard-pagination","last_synced_at":"2025-10-04T01:30:52.883Z","repository":{"id":48812923,"uuid":"90418899","full_name":"php-telegram-bot/inline-keyboard-pagination","owner":"php-telegram-bot","description":"Telegram Bot inline keyboard pagination for CallbackQuery","archived":false,"fork":true,"pushed_at":"2021-07-10T16:01:41.000Z","size":102,"stargazers_count":29,"open_issues_count":2,"forks_count":13,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2024-12-30T21:36:45.302Z","etag":null,"topics":["callback","inline","pagination","php7","php8","query","telegram","telegram-bot"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"lartie/Telegram-Bot-Pagination","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-telegram-bot.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-05T21:46:41.000Z","updated_at":"2024-04-26T20:49:03.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/php-telegram-bot/inline-keyboard-pagination","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-telegram-bot%2Finline-keyboard-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-telegram-bot%2Finline-keyboard-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-telegram-bot%2Finline-keyboard-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-telegram-bot%2Finline-keyboard-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-telegram-bot","download_url":"https://codeload.github.com/php-telegram-bot/inline-keyboard-pagination/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235208940,"owners_count":18953003,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["callback","inline","pagination","php7","php8","query","telegram","telegram-bot"],"created_at":"2024-09-24T20:12:48.598Z","updated_at":"2025-10-04T01:30:52.549Z","avatar_url":"https://github.com/php-telegram-bot.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Telegram Bot Inline Keyboard Pagination][github-tgbot-ikp]\n\n[![Scrutinizer Code Quality][code-quality-badge]][code-quality]\n[![Codecov][code-coverage-badge]][code-coverage]\n[![Build Status][build-status-badge]][build-status]\n\n[![Latest Stable Version][latest-version-badge]][packagist-tgbot-ikp]\n[![Total Downloads][total-downloads-badge]][packagist-tgbot-ikp]\n[![License][license-badge]][license]\n\n- [Installation](#installation)\n    - [Composer](#composer)\n- [Usage](#usage)\n    - [Test Data](#test-data)\n    - [How To Use](#how-to-use)\n- [Code Quality](#code-quality)\n- [License](#license)\n\n## Installation\n\n### Composer\n\n```bash\ncomposer require php-telegram-bot/inline-keyboard-pagination\n```\n\n## Usage\n\n### Test Data\n\n```php\n$items        = range(1, 100); // required. \n$command      = 'testCommand'; // optional. Default: pagination\n$selectedPage = 10;            // optional. Default: 1\n$labels       = [              // optional. Change button labels (showing defaults)\n    'default'  =\u003e '%d',\n    'first'    =\u003e '« %d',\n    'previous' =\u003e '‹ %d',\n    'current'  =\u003e '· %d ·',\n    'next'     =\u003e '%d ›',\n    'last'     =\u003e '%d »',\n];\n\n// optional. Change the callback_data format, adding placeholders for data (showing default)\n$callbackDataFormat = 'command={COMMAND}\u0026oldPage={OLD_PAGE}\u0026newPage={NEW_PAGE}'\n```\n\n### How To Use\n\n```php\n// Define inline keyboard pagination.\n$ikp = new InlineKeyboardPagination($items, $command);\n$ikp-\u003esetMaxButtons(7, true); // Second parameter set to always show 7 buttons if possible.\n$ikp-\u003esetLabels($labels);\n$ikp-\u003esetCallbackDataFormat($callbackDataFormat);\n\n// Get pagination.\n$pagination = $ikp-\u003egetPagination($selectedPage);\n\n// or, in 2 steps.\n$ikp-\u003esetSelectedPage($selectedPage);\n$pagination = $ikp-\u003egetPagination();\n```\n\nNow, `$pagination['keyboard']` is basically a row that contains the pagination.\n\n```php\n// Use it in your request.\nif (!empty($pagination['keyboard'])) {\n    //$pagination['keyboard'][0]['callback_data']; // command=testCommand\u0026oldPage=10\u0026newPage=1\n    //$pagination['keyboard'][1]['callback_data']; // command=testCommand\u0026oldPage=10\u0026newPage=7\n    \n    ...\n    $data['reply_markup'] = [\n        'inline_keyboard' =\u003e [\n            $pagination['keyboard'],\n        ],\n    ];\n    ...\n}\n```\n\nTo get the callback data, you can use the provided helper method (only works when using the default callback data format):\n\n```php\n// e.g. Callback data.\n$callback_data = 'command=testCommand\u0026oldPage=10\u0026newPage=1';\n\n$params = InlineKeyboardPagination::getParametersFromCallbackData($callbackData);\n\n//$params = [\n//    'command' =\u003e 'testCommand',\n//    'oldPage' =\u003e '10',\n//    'newPage' =\u003e '1',\n//];\n\n// or, just use PHP directly if you like. (literally what the helper does!)\nparse_str($callbackData, $params);\n```\n\n## Code Quality\n\nRun the PHPUnit tests via Composer script.\n\n```bash\ncomposer test\n```\n\n## License\n\nThe MIT License (MIT). Please see [License File][license] for more information.\n\nProject based on [Telegram Bot Pagination][github-lartie-tbp] by [lartie][github-lartie].\n\n\n[github-tgbot-ikp]: https://github.com/php-telegram-bot/inline-keyboard-pagination \"PHP Telegram Bot Inline Keyboard Pagination on GitHub\"\n[packagist-tgbot-ikp]: https://packagist.org/packages/php-telegram-bot/inline-keyboard-pagination \"PHP Telegram Bot Inline Keyboard Pagination on Packagist\"\n[license]: https://github.com/php-telegram-bot/inline-keyboard-pagination/blob/master/LICENSE \"PHP Telegram Bot Inline Keyboard Pagination license\"\n\n[code-quality-badge]: https://img.shields.io/scrutinizer/g/php-telegram-bot/inline-keyboard-pagination.svg\n[code-quality]: https://scrutinizer-ci.com/g/php-telegram-bot/inline-keyboard-pagination/?branch=master \"Code quality on Scrutinizer\"\n[code-coverage-badge]: https://img.shields.io/codecov/c/github/php-telegram-bot/inline-keyboard-pagination.svg\n[code-coverage]: https://codecov.io/gh/php-telegram-bot/inline-keyboard-pagination \"Code coverage on Codecov\"\n[build-status-badge]: https://img.shields.io/travis/php-telegram-bot/inline-keyboard-pagination.svg\n[build-status]: https://travis-ci.com/php-telegram-bot/inline-keyboard-pagination \"Build status on Travis-CI\"\n\n[latest-version-badge]: https://img.shields.io/packagist/v/php-telegram-bot/inline-keyboard-pagination.svg\n[total-downloads-badge]: https://img.shields.io/packagist/dt/php-telegram-bot/inline-keyboard-pagination.svg\n[license-badge]: https://img.shields.io/packagist/l/php-telegram-bot/inline-keyboard-pagination.svg\n\n[github-lartie-tbp]: https://github.com/lartie/Telegram-Bot-Pagination \"Telegram Bot Pagination by Lartie on GitHub\"\n[github-lartie]: https://github.com/lartie \"Lartie on GitHub\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-telegram-bot%2Finline-keyboard-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-telegram-bot%2Finline-keyboard-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-telegram-bot%2Finline-keyboard-pagination/lists"}