{"id":13519388,"url":"https://github.com/sampart/WhiteOctoberPagerfantaBundle","last_synced_at":"2025-03-31T12:31:37.427Z","repository":{"id":1437868,"uuid":"1666669","full_name":"sampart/WhiteOctoberPagerfantaBundle","owner":"sampart","description":"Bundle to use Pagerfanta with Symfony","archived":true,"fork":false,"pushed_at":"2020-11-15T19:32:54.000Z","size":207,"stargazers_count":469,"open_issues_count":14,"forks_count":110,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-05-19T10:10:05.427Z","etag":null,"topics":["pagerfanta","php","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sampart.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code_of_conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-04-26T18:57:47.000Z","updated_at":"2024-03-19T10:34:19.000Z","dependencies_parsed_at":"2022-07-18T21:35:00.086Z","dependency_job_id":null,"html_url":"https://github.com/sampart/WhiteOctoberPagerfantaBundle","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sampart%2FWhiteOctoberPagerfantaBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sampart%2FWhiteOctoberPagerfantaBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sampart%2FWhiteOctoberPagerfantaBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sampart%2FWhiteOctoberPagerfantaBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sampart","download_url":"https://codeload.github.com/sampart/WhiteOctoberPagerfantaBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246258862,"owners_count":20748573,"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":["pagerfanta","php","symfony-bundle"],"created_at":"2024-08-01T05:01:58.315Z","updated_at":"2025-03-31T12:31:36.848Z","avatar_url":"https://github.com/sampart.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"This project is no longer maintained. If you are using it with Symfony 3.4, 4.4 or 5, you may want to use [this fork](https://github.com/BabDev/BabDevPagerfantaBundle) instead.\n\n# WhiteOctoberPagerfantaBundle\n\n[![Build Status](https://travis-ci.org/whiteoctober/WhiteOctoberPagerfantaBundle.png?branch=master)](https://travis-ci.org/whiteoctober/WhiteOctoberPagerfantaBundle) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/whiteoctober/WhiteOctoberPagerfantaBundle/badges/quality-score.png?s=5bbc990b8c05b7dcc69cd0cfe7d8d46e9944c530)](https://scrutinizer-ci.com/g/whiteoctober/WhiteOctoberPagerfantaBundle/) [![SensioLabsInsight](https://insight.sensiolabs.com/projects/e0838383-1c8d-406f-9874-a76c08b7d217/mini.png)](https://insight.sensiolabs.com/projects/e0838383-1c8d-406f-9874-a76c08b7d217)\n\nBundle to use [Pagerfanta](https://github.com/whiteoctober/Pagerfanta) with [Symfony](https://github.com/symfony/symfony).\n\n**Note:** If you are using a 2.0.x release of Symfony2, please use the `symfony2.0` branch of this bundle.  The master branch of this bundle tracks the Symfony master branch.\n\nThe bundle includes:\n\n  * Twig function to render pagerfantas with views and options.\n  * Way to use easily views.\n  * Way to reuse options in views.\n  * Basic CSS for the DefaultView.\n\nInstallation\n------------\n\n1) Use [Composer](https://getcomposer.org/) to download the library\n\n```\nphp composer.phar require white-october/pagerfanta-bundle\n```\n\n2) Then add the WhiteOctoberPagerfantaBundle to your application:\n\nIn Symfony \u003c 4:\n\n```php\n// app/AppKernel.php\npublic function registerBundles()\n{\n    return array(\n        // ...\n        new WhiteOctober\\PagerfantaBundle\\WhiteOctoberPagerfantaBundle(),\n        // ...\n    );\n}\n```\n\nIn Symfony 4 with Symfony Flex this will be done automatically for you.\n\n3) Configure and use things!\n\nA) **Creating a Pager** is shown on the [Pagerfanta](https://github.com/whiteoctober/Pagerfanta) documentation. If you're using the Doctrine ORM, you'll want to use the [DoctrineORMAdapter](https://github.com/whiteoctober/Pagerfanta#doctrineormadapter)\n\nB) **Rendering in Twig** is shown below in the [Rendering Pagerfantas](#rendering-pagerfantas) section.\n\nC) **Configuration** is shown through this document\n\nRendering Pagerfantas\n---------------------\n\nFirst, you'll need to pass an instance of Pagerfanta as a parameter into your template.\nFor example:\n\n```php\n$adapter = new DoctrineORMAdapter($queryBuilder);\n$pagerfanta = new Pagerfanta($adapter);\nreturn $this-\u003erender('@YourApp/Main/example.html.twig', [\n    'my_pager' =\u003e $pagerfanta,\n]);\n```\n\nYou then call the the Pagerfanta Twig extension, passing in the Pagerfanta instance.\nThe routes are generated automatically for the current route using the variable \"page\" to propagate the page number.\nBy default, the bundle uses the *DefaultView* with the *default* name. The default syntax is:\n\n```twig\n\u003cdiv class=\"pagerfanta\"\u003e\n    {{ pagerfanta(my_pager) }}\n\u003c/div\u003e\n```\n\nBy default, the \"page\" variable is also added for the link to the first page. To \ndisable the generation of `?page=1` in the url, simply set the `omitFirstPage` option\nto `true` when calling the `pagerfanta` twig function:\n\n```\n{{ pagerfanta(my_pager, 'default', { 'omitFirstPage': true}) }}\n```\n\nYou can omit template parameter to make function call shorter, default template will be used:\n\n```\n{{ pagerfanta(my_pager, { 'omitFirstPage': true }) }}\n```\n\nIf you have multiple pagers on one page, you'll need to change the name of the `page` parameter.\nHere's an example:\n\n```twig\n\u003cdiv class=\"pagerfanta\"\u003e\n    {{ pagerfanta(my_other_pager, 'default', {'pageParameter': '[page_other]'}) }}\n\u003c/div\u003e\n```\n\nNote the square brackets around `page_other`; this won't work without them.\n\n### Twitter Bootstrap\n\nThe bundle also has a Twitter Bootstrap view.\n\nFor Bootstrap 2:\n\n```twig\n\u003cdiv class=\"pagerfanta\"\u003e\n    {{ pagerfanta(my_pager, 'twitter_bootstrap') }}\n\u003c/div\u003e\n```\n\nFor Bootstrap 3:\n\n```twig\n\u003cdiv class=\"pagerfanta\"\u003e\n    {{ pagerfanta(my_pager, 'twitter_bootstrap3') }}\n\u003c/div\u003e\n```\n\n\nFor Bootstrap 4:\n\n```twig\n\u003cdiv class=\"pagerfanta\"\u003e\n    {{ pagerfanta(my_pager, 'twitter_bootstrap4') }}\n\u003c/div\u003e\n```\n### Custom template\n\n\nIf you want to use a custom template, add another argument:\n\n```twig\n\u003cdiv class=\"pagerfanta\"\u003e\n    {{ pagerfanta(my_pager, 'my_template') }}\n\u003c/div\u003e\n```\n\nWith options:\n\n```twig\n{{ pagerfanta(my_pager, 'default', { 'proximity': 2}) }}\n```\n\nSee the [Pagerfanta documentation](https://github.com/whiteoctober/Pagerfanta) for the list of possible parameters.\n\nRendering the page of items itself\n----------------------------------\n\nThe items can be retrieved using `currentPageResults`. For example:\n\n```twig\n{% for item in my_pager.currentPageResults %}\n    \u003cul\u003e\n        \u003cli\u003e{{ item.id }}\u003c/li\u003e\n    \u003c/ul\u003e\n{% endfor %}\n```\n\nTranslate in your language\n--------------------------\n\nThe bundle also offers two views to translate the *default* and the\n*twitter bootstrap* views.\n\n```twig\n{{ pagerfanta(my_pager, 'default_translated') }}\n\n{{ pagerfanta(my_pager, 'twitter_bootstrap_translated') }}\n```\n\nAdding Views\n------------\n\nThe views are added to the container with the *pagerfanta.view* tag:\n\nXML\n\n```xml\n\u003cservice id=\"pagerfanta.view.default\" class=\"Pagerfanta\\View\\DefaultView\" public=\"false\"\u003e\n    \u003ctag name=\"pagerfanta.view\" alias=\"default\" /\u003e\n\u003c/service\u003e\n```\n\nYAML\n\n```yml\nservices:\n    pagerfanta.view.default:\n        class: Pagerfanta\\View\\DefaultView\n        public: false\n        tags: [{ name: pagerfanta.view, alias: default }]\n```\n\nReusing Options\n---------------\n\nSometimes you want to reuse options of a view in your project, and you don't\nwant to write them all the times you render a view, or you can have different\nconfigurations for a view and you want to save them in a place to be able to\nchange them easily.\n\nFor this you have to define views with the special view *OptionableView*:\n\n```yml\nservices:\n    pagerfanta.view.my_view_1:\n        class: Pagerfanta\\View\\OptionableView\n        arguments:\n            - @pagerfanta.view.default\n            - { proximity: 2, prev_message: Anterior, next_message: Siguiente }\n        public: false\n        tags: [{ name: pagerfanta.view, alias: my_view_1 }]\n    pagerfanta.view.my_view_2:\n        class: Pagerfanta\\View\\OptionableView\n        arguments:\n            - @pagerfanta.view.default\n            - { proximity: 5 }\n        public: false\n        tags: [{ name: pagerfanta.view, alias: my_view_2 }]\n```\n\nAnd using then:\n\n```twig\n{{ pagerfanta(my_pager, 'my_view_1') }}\n{{ pagerfanta(my_pager, 'my_view_2') }}\n```\n\nThe easiest way to render pagerfantas (or paginators!) ;)\n\nBasic CSS for the default view\n------------------------------\n\nThe bundles comes with basic CSS for the default view so you can get started with a good paginator faster.\nOf course you can change it, use another one or create your own view.\n\n```html\n\u003clink rel=\"stylesheet\" href=\"{{ asset('bundles/whiteoctoberpagerfanta/css/pagerfantaDefault.css') }}\" type=\"text/css\" media=\"all\" /\u003e\n```\n\nConfiguration\n-------------\n\nIt's possible to configure the default view for all rendering in your\nconfiguration file:\n\n```yml\nwhite_october_pagerfanta:\n    default_view: my_view_1\n```\n\nMaking bad page numbers return a HTTP 500\n-----------------------------------------\n\nRight now when the page is out of range or not a number,\nthe server returns a 404 response by default.\nYou can set the following parameters to different than default value\n`to_http_not_found` (ie. null) to show a 500 exception when the\nrequested page is not valid instead.\n\n```yml\n// app/config/config.yml\nwhite_october_pagerfanta:\n    exceptions_strategy:\n        out_of_range_page:        ~\n        not_valid_current_page:   ~\n```\n\nMore information\n----------------\n\nFor more advanced documentation, check the [Pagerfanta documentation](https://github.com/whiteoctober/Pagerfanta/blob/master/README.md).\n\nContributing\n-------------\n\nWe welcome contributions to this project, including pull requests and issues (and discussions on existing issues).\n\nIf you'd like to contribute code but aren't sure what, the [issues list](https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle/issues) is a good place to start.\nIf you're a first-time code contributor, you may find Github's guide to [forking projects](https://guides.github.com/activities/forking/) helpful.\n\nAll contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our [code of conduct](code_of_conduct.md).\n\nAcknowledgements\n-----------------\n\nPablo Díez (pablodip@gmail.com) for most of the work on the first versions of this bundle.\n\nThis project was originally located at https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle.\n\nLicense\n-------\n\nPagerfanta is licensed under the MIT License. See the LICENSE file for full\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsampart%2FWhiteOctoberPagerfantaBundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsampart%2FWhiteOctoberPagerfantaBundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsampart%2FWhiteOctoberPagerfantaBundle/lists"}