PHPackages                             heimrichhannot/contao-filter-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. heimrichhannot/contao-filter-bundle

ActiveContao-bundle[Search &amp; Filtering](/categories/search)

heimrichhannot/contao-filter-bundle
===================================

A generic contao filter.

1.30.5(7mo ago)410.3k1[3 issues](https://github.com/heimrichhannot/contao-filter-bundle/issues)[1 PRs](https://github.com/heimrichhannot/contao-filter-bundle/pulls)3LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0CI failing

Since Feb 27Pushed 7mo ago5 watchersCompare

[ Source](https://github.com/heimrichhannot/contao-filter-bundle)[ Packagist](https://packagist.org/packages/heimrichhannot/contao-filter-bundle)[ RSS](/packages/heimrichhannot-contao-filter-bundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (39)Versions (271)Used By (3)

Contao filter bundle
====================

[](#contao-filter-bundle)

[![](https://camo.githubusercontent.com/a5b6aacb14ca99ce8d673f08bfc8874e6b37d4c8717fbd91ec2d04f9db4402f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d66696c7465722d62756e646c652e737667)](https://camo.githubusercontent.com/a5b6aacb14ca99ce8d673f08bfc8874e6b37d4c8717fbd91ec2d04f9db4402f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6865696d7269636868616e6e6f742f636f6e74616f2d66696c7465722d62756e646c652e737667)[![](https://camo.githubusercontent.com/07e10cde48389a54d7d3da99638d3838d95fba0a0b67d09fb5538c047da80dac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d66696c7465722d62756e646c652e737667)](https://camo.githubusercontent.com/07e10cde48389a54d7d3da99638d3838d95fba0a0b67d09fb5538c047da80dac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6865696d7269636868616e6e6f742f636f6e74616f2d66696c7465722d62756e646c652e737667)

This bundle offers a generic filter module to use with arbitrary contao entities containing standard filter with initial filters and filter form types including [symfony form type representations](https://symfony.com/doc/current/reference/forms/types).

Features
--------

[](#features)

- Form handling using symfony form component
- Form rendering by using symfony form templates (currently available: bootstrap 3-5, foundation, div, table)
- Numerous [symfony form types](https://symfony.com/doc/4.4/reference/forms/types.html) supported
- Highly customizable and detached from tl\_module table
- Label/Message handling using symfony translations
- Render form always empty (without user selection)
- Merge data over multiple filter forms with same form name
- Default Values (can be overwritten by user)
- Initial Values (can`t be overwritten by user)
- Stores filter data in session (no GET parameter URL remnant)
- Content element "Filter-Preselect" with optional redirect functionality to preselect filter on given page
- Content element "Filter-Hyperlink" with filter preselect feature
- Integrations:
    - `codefog/contao-news_categories`
    - `codefog/tags-bundle`
    - `heimrichhannot/contao-categories-bundle`
    - `heimrichhannot/contao-encore-bundle`

Usage
-----

[](#usage)

### Install

[](#install)

1. Install with composer or contao manager

    ```
    composer require heimrichhannot/contao-filter-bundle

    ```
2. Update database

We recommend to use this bundle toghether with [List Bundle](https://github.com/heimrichhannot/contao-list-bundle) and [Reader Bundle](https://github.com/heimrichhannot/contao-reader-bundle).

### Setup

[](#setup)

1. Create a filter configuration within System -&gt; Filter &amp; sort configuration
2. Add filter elements to the filter config.
3. If you want to show the filter somewhere (for example to filter a list), create a filter/sort frontend module.

### Wrapper elements (DateRange, ProximitySearch, ...)

[](#wrapper-elements-daterange-proximitysearch-)

The Wrapper element has to be places **before** the fields associated with them. For example the date\_range wrapper element needs to be placed before the two associated date fields.

### Preselect

[](#preselect)

Filter Bundle Forms are not typical GET-Forms, so it is not possible to simple copy the filter urls to share or bookmark a filtered list. To overcome this limitation, preselect urls can be generated. Preselect urls for the current filter can be found within template variabled, you can create a preselect content element or get the url programmatically from the FilterConfig.

#### Template variables

[](#template-variables)

If a filter is set, the variable `preselectUrl` contains the preselection url for the current filter. It's available in the filter templates and the frontend module template.

You can for example create a copy preselect url button:

```
{% if preselectUrl is defined and preselectUrl is not empty %}

   Filtervorauswahllink kopieren

{% endif %}
```

#### Content element

[](#content-element)

You can use one of the following content elements:

- "Filter-Preselect" with optional redirect functionality to preselect filter on given page
- "Filter-Hyperlink" with filter preselect feature

#### FilterConfig

[](#filterconfig)

You can generate the preselect link from the FilterConfig instance

```
