{"id":26796447,"url":"https://github.com/peterujah/pagination","last_synced_at":"2025-03-29T18:18:42.877Z","repository":{"id":50392934,"uuid":"440239446","full_name":"peterujah/pagination","owner":"peterujah","description":"Simple PHP library to generate website pagination","archived":false,"fork":false,"pushed_at":"2024-02-17T12:23:29.000Z","size":86,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-03-17T13:41:42.990Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterujah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-12-20T16:38:58.000Z","updated_at":"2023-12-17T16:48:51.000Z","dependencies_parsed_at":"2022-09-15T19:30:25.049Z","dependency_job_id":"0af89777-0510-49ca-aabf-3a6d0dc44ce3","html_url":"https://github.com/peterujah/pagination","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"2a2bea5c95387ee358530a44890ae43440bb2029"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterujah%2Fpagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterujah%2Fpagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterujah%2Fpagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterujah%2Fpagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterujah","download_url":"https://codeload.github.com/peterujah/pagination/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246223304,"owners_count":20743168,"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":[],"created_at":"2025-03-29T18:18:42.390Z","updated_at":"2025-03-29T18:18:42.871Z","avatar_url":"https://github.com/peterujah.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Pagination \n\nPagination is a simple package that can generate HTML to navigate between listing pages.\n\nIt takes as parameter values the type of navigation to generate and the total number of entries in the listing.\n\nThe class generates HTML with links to allow the user to click and go to the other listing pages considering the current listing page number.\n\nThe class's navigation can be either a list of links or just a group of links pointing to each listing page.\n\nDevelopers can configure the presentation of the navigation using custom CSS styles or bootstrap pagination.\n\n\n## Installation\n\nInstallation is super-easy via Composer:\n```md\ncomposer require peterujah/pagination\n```\n\n# USAGES\n\nPagination can be used as an HTML hyperlink or HTML unordered list\n\n```php \n use Peterujah\\NanoBlock\\Pagination;\n $paging = new Pagination($rowCount, Pagination::LIST);\n $paging = new Pagination($rowCount, Pagination::LINK);\n```\n  \nDump array \n  \n```php \n $paging = new Pagination(100, Pagination::LIST);\n $paging-\u003esetLimit(20);\n $paging-\u003esetCurrentPage($_GET[\"page\"]??1)-\u003eshow();\n ```\n   \n```php \n $paging = new Pagination(100, Pagination::LIST);\n $paging-\u003esetLimit(20);\n $html = $paging-\u003esetCurrentPage($_GET[\"page\"]??1)-\u003eget();\n```\n\nUse built-in css style, only work with `$paging-\u003eshow()` method\n\n``` php \n$paging-\u003esetAllowCss(true);\n```\n\n## Constants\nInitalisation options `new Pagination($rowCount, Pagination::LINK)`\n\n| Options         | Description                                                                         |\n|-----------------|-------------------------------------------------------------------------------------|\n| LIST            | Retrieve result as an html unordered list                                           |\n| LINK            | Retrieve result in HTML hyperlink                                                   |\n\n## Methods\n\n| Method                    | Description                                                                         |\n|---------------------------|-------------------------------------------------------------------------------------|\n| setLimit(int)             | Set query row display limit per page                                                |\n| setCurrentPage(int)       | Set current paging number                                                           |\n| addQuery(string, string)  | Add query parameter (key, value)                                                    |\n| setQueries(array)         | Set query parameters array(key =\u003e value)                                            |\n| setAllowCss(bool)         | Enable default paging buttons styling                                               |\n| setClass(string)          | Set a custom class name for paging list items `li`                                  |\n| setContainerClass(string) | Set a custom class name for pagination unordered list `ul`                          |\n| setTruncate(int)          | Set pagination truncate offset                                                      |\n| getSize() :int            | Get total pagination calculated cell pages                                          |\n| getOffset() :int          | Get pagination next page start offset                                               |\n| get() :string|false       | Returns pagination generated html                                                   |\n| show() :void              | Display pagination buttons                                                          |\n\n\n\n## Full usage example\n\nExample: Specify the total number of rows in your table `findTotalUsers :(int)`, then select only the number of items to show per page `findUsers(startOffset, limitPerPage)`\n\n```php\nuse Peterujah\\NanoBlock\\Pagination;\n// Configure page limit\n$queryLimit = 30;\n$queryPage = $_GET[\"n\"]??1;\n$queryStart = ($queryPage - 1) * $queryLimit;\n\n// Query your database table\n$users = (object) array(\n    \"users\" =\u003e $conn-\u003efindUsers($queryStart, $queryLimit),\n    \"rowCount\" =\u003e $conn-\u003efindTotalUsers()\n);\n\n// Initialize Pagination\n$paging = new Pagination($users-\u003erowCount, Pagination::LIST);\n$paging-\u003esetLimit($queryLimit);\n$paging-\u003esetCurrentPage($queryPage);\n\n// Display your contents\nforeach($users-\u003eusers as $row){\n    echo \"\u003cdiv\u003e{$row-\u003euserFullname}\u003c/div\u003e\";\n}\n// Add pagination buttons\necho \"\u003cnav aria-label='Page navigation'\u003e\";\necho $paging-\u003eget();\necho \"\u003c/nav\u003e\";\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterujah%2Fpagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterujah%2Fpagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterujah%2Fpagination/lists"}