PagerfantaBundle

Documentation

Available Views

Default Views

All of the views provided in the pagerfanta/core package are available by default for use with this bundle.

The below table lists the view names and the corresponding class.

View NameClass Name
defaultPagerfanta\View\DefaultView
foundation6Pagerfanta\View\Foundation6View
semantic_uiPagerfanta\View\SemanticUiView
twitter_bootstrapPagerfanta\View\TwitterBootstrapView
twitter_bootstrap3Pagerfanta\View\TwitterBootstrap3View
twitter_bootstrap4Pagerfanta\View\TwitterBootstrap4View
twitter_bootstrap5Pagerfanta\View\TwitterBootstrap5View

Sequential Views

The sequential views were introduced in PagerfantaBundle 4.7.

The views above render numbered page links, so they can only render offset pagers. The sequential views render only the links to the previous and next pages, so they can render any pager, including cursor pagers.

A sequential view is available for each of the default views, all using the Pagerfanta\View\SequentialView class.

View NameTemplate Class Name
default_sequentialPagerfanta\View\Template\DefaultTemplate
foundation6_sequentialPagerfanta\View\Template\Foundation6Template
semantic_ui_sequentialPagerfanta\View\Template\SemanticUiTemplate
twitter_bootstrap_sequentialPagerfanta\View\Template\TwitterBootstrapTemplate
twitter_bootstrap3_sequentialPagerfanta\View\Template\TwitterBootstrap3Template
twitter_bootstrap4_sequentialPagerfanta\View\Template\TwitterBootstrap4Template
twitter_bootstrap5_sequentialPagerfanta\View\Template\TwitterBootstrap5Template

When the pagerfanta() Twig function is given a pager which its view cannot render, the pager is rendered with the default sequential view.

Twig View

This bundle provides a Pagerfanta view which renders a Twig template. If you have not already, you will need to install the pagerfanta/twig package.

The below table lists the available templates and the CSS framework they correspond to.

Template NameFramework
@BabDevPagerfanta/default.html.twigNone (Pagerfanta's default view)
@BabDevPagerfanta/foundation6.html.twigFoundation (version 6.x)
@BabDevPagerfanta/semantic_ui.html.twigSemantic UI (version 2.x)
@BabDevPagerfanta/tailwind.html.twigTailwind CSS
@BabDevPagerfanta/twitter_bootstrap.html.twigBootstrap (version 2.x)
@BabDevPagerfanta/twitter_bootstrap3.html.twigBootstrap (version 3.x)
@BabDevPagerfanta/twitter_bootstrap4.html.twigBootstrap (version 4.x)
@BabDevPagerfanta/twitter_bootstrap5.html.twigBootstrap (version 5.x)

The labels of the "Previous" and "Next" buttons are localizable in the Twig templates.

The Twig view can render any pager. Offset pagers are rendered with numbered page links, and all other pagers (such as cursor pagers) are rendered with only the previous and next links using the same templates.

See the Pagerfanta documentation for more information about building a Twig template.

Default View CSS

The bundle comes with basic CSS for the default view so you can get started quickly.

<link rel="stylesheet" href="{{ asset('bundles/babdevpagerfanta/css/pagerfanta.css') }}">

If you are using the AssetMapper component in your application, the CSS file can also be loaded through that component. Please see the Symfony documentation for examples of importing assets from bundles and importing assets outside your /assets directory.