heimrichhannot / contao-list-bundle
This bundle offers a generic list module to use with arbitrary contao entities containing standard list handling like pagination, sorting, and filtering.
Installs: 6 668
Dependents: 7
Suggesters: 4
Security: 0
Stars: 3
Watchers: 6
Forks: 0
Open Issues: 6
Type:contao-bundle
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.9
- heimrichhannot-contao-components/imagesloaded: 4.1.*
- heimrichhannot-contao-components/jscroll: 2.3.*
- heimrichhannot-contao-components/masonry: >=4.2, <=4.3
- heimrichhannot/contao-be_explanation-bundle: ^2.2
- heimrichhannot/contao-config-element-type-bundle: ^0.2
- heimrichhannot/contao-encore-contracts: ^1.0
- heimrichhannot/contao-filter-bundle: ^1.19
- heimrichhannot/contao-twig-support-bundle: ^0.2|^1.0
- heimrichhannot/contao-utils-bundle: ^2.128
- symfony/config: ^4.4||^5.4
- symfony/console: ^4.4||^5.4
- symfony/dependency-injection: ^4.4||^5.4
- symfony/event-dispatcher: ^4.4||^5.4
- symfony/event-dispatcher-contracts: ^1||^2||^3
- symfony/http-kernel: ^4.4||^5.4
- symfony/polyfill-php80: ^v1.24.0
- symfony/service-contracts: ^1.0 || ^2.0 || ^3.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: 1.1.*
- friendsofphp/php-cs-fixer: ^2.2
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/php-token-stream: ^1.4|^2.0|^3.0
- phpunit/phpunit: ^6.5
- phpunit/phpunit-mock-objects: ^4.0|^5.0
- satooshi/php-coveralls: ^2.0
- symfony/phpunit-bridge: ^3.2
Suggests
- heimrichhannot/contao-reader-bundle: This bundle offers a generic reader module to use with arbitrary contao entities containing standard reader specific functionality like field output, images and auto_item handling.
Conflicts
- heimrichhannot/contao-reader-bundle: <=1.0.0-beta54
- dev-master
- 1.54.0
- 1.53.5
- 1.53.4
- 1.53.3
- 1.53.2
- 1.53.1
- 1.53.0
- 1.52.2
- 1.52.1
- 1.52.0
- 1.51.3
- 1.51.2
- 1.51.1
- 1.51.0
- 1.50.3
- 1.50.2
- 1.50.1
- 1.50.0
- 1.49.2
- 1.49.1
- 1.49.0
- 1.48.10
- 1.48.9
- 1.48.8
- 1.48.7
- 1.48.6
- 1.48.5
- 1.48.4
- 1.48.3
- 1.48.2
- 1.48.1
- 1.48.0
- 1.47.3
- 1.47.2
- 1.47.1
- 1.47.0
- 1.46.0
- 1.45.0
- 1.44.2
- 1.44.1
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.40.3
- 1.40.2
- 1.40.1
- 1.40.0
- 1.39.1
- 1.39.0
- 1.38.0
- 1.37.1
- 1.37.0
- 1.36.0
- 1.35.1
- 1.35.0
- 1.34.0
- 1.33.8
- 1.33.7
- 1.33.6
- 1.33.5
- 1.33.4
- 1.33.3
- 1.33.2
- 1.33.1
- 1.33.0
- 1.32.0
- 1.31.3
- 1.31.2
- 1.31.1
- 1.31.0
- 1.30.7
- 1.30.6
- 1.30.5
- 1.30.4
- 1.30.3
- 1.30.2
- 1.30.1
- 1.30.0
- 1.29.0
- 1.28.1
- 1.28.0
- 1.27.1
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.3
- 1.24.2
- 1.24.1
- 1.24.0
- 1.23.2
- 1.23.1
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.4
- 1.20.3
- 1.20.2
- 1.20.1
- 1.20.0
- 1.19.3
- 1.19.2
- 1.19.1
- 1.19.0
- 1.18.0
- 1.17.3
- 1.17.2
- 1.17.1
- 1.17.0
- 1.16.3
- 1.16.2
- 1.16.1
- 1.16.0
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.4
- 1.14.3
- 1.14.2
- 1.14.1
- 1.14.0
- 1.13.0
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.11
- 1.9.10
- 1.9.9
- 1.9.8
- 1.9.7
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.1
- 1.1.0
- 1.0.0
- 1.0.0-beta109
- 1.0.0-beta108
- 1.0.0-beta107
- 1.0.0-beta106
- 1.0.0-beta105
- 1.0.0-beta104
- 1.0.0-beta103
- 1.0.0-beta102
- 1.0.0-beta101
- 1.0.0-beta100
- 1.0.0-beta99
- 1.0.0-beta98
- 1.0.0-beta97
- 1.0.0-beta96
- 1.0.0-beta95
- 1.0.0-beta94
- 1.0.0-beta93
- 1.0.0-beta92
- 1.0.0-beta91
- 1.0.0-beta90
- 1.0.0-beta89
- 1.0.0-beta88
- 1.0.0-beta87
- 1.0.0-beta86
- 1.0.0-beta85
- 1.0.0-beta84
- 1.0.0-beta83
- 1.0.0-beta82
- 1.0.0-beta81
- 1.0.0-beta80
- 1.0.0-beta79
- 1.0.0-beta78
- 1.0.0-beta77
- 1.0.0-beta76
- 1.0.0-beta75
- 1.0.0-beta74
- 1.0.0-beta73
- 1.0.0-beta72
- 1.0.0-beta71
- 1.0.0-beta70
- 1.0.0-beta69
- 1.0.0-beta68
- 1.0.0-beta67
- 1.0.0-beta66
- 1.0.0-beta65
- 1.0.0-beta64
- 1.0.0-beta63
- 1.0.0-beta62
- 1.0.0-beta61
- 1.0.0-beta60
- 1.0.0-beta59
- 1.0.0-beta58
- 1.0.0-beta57
- 1.0.0-beta56
- 1.0.0-beta55
- 1.0.0-beta54
- 1.0.0-beta53
- 1.0.0-beta52
- 1.0.0-beta51
- 1.0.0-beta50
- 1.0.0-beta49
- 1.0.0-beta48
- 1.0.0-beta47
- 1.0.0-beta46
- 1.0.0-beta45
- 1.0.0-beta44
- 1.0.0-beta43
- 1.0.0-beta42
- 1.0.0-beta41
- 1.0.0-beta40
- 1.0.0-beta39
- 1.0.0-beta38
- 1.0.0-beta37
- 1.0.0-beta36
- 1.0.0-beta35
- 1.0.0-beta34
- 1.0.0-beta33
- 1.0.0-beta32
- 1.0.0-beta31
- 1.0.0-beta30
- 1.0.0-beta29
- 1.0.0-beta28
- 1.0.0-beta27
- 1.0.0-beta26
- 1.0.0-beta25
- 1.0.0-beta24
- 1.0.0-beta23
- 1.0.0-beta22
- 1.0.0-beta21
- 1.0.0-beta20
- 1.0.0-beta19
- 1.0.0-beta18
- 1.0.0-beta17
- 1.0.0-beta16
- 1.0.0-beta15
- 1.0.0-beta14
- 1.0.0-beta13
- 1.0.0-beta12
- 1.0.0-beta11
- 1.0.0-beta10
- 1.0.0-beta9
- 1.0.0-beta8
- 1.0.0-beta7
- 1.0.0-beta6
- 1.0.0-beta5
- 1.0.0-beta4
- 1.0.0-beta3
- 1.0.0-beta2
- 1.0.0-beta1
- 1.0.0-beta
- dev-feature/list_config
- dev-contao5
- dev-feature/extract_model_support
- dev-feature/list_extension_multilingual
- dev-feature/list_extension
- dev-feature/update_dc_multilingual_integration
- dev-feature/list_controller
- dev-feature/config_element_event
- dev-feature-jqueryfree-page-loading
- dev-feature/listContextVariables
- dev-feature/live-region
This package is auto-updated.
Last update: 2024-12-18 10:51:18 UTC
README
This bundle offers a generic list module to use with arbitrary contao entities containing standard list handling like pagination, sorting, and filtering.
It makes it possible to generate lists not only for events, news or faq's but with every DCA you like.
Features
- generic list module to use with arbitrary contao entities
- support all form of standard list handling like pagination, sorting, filtering
- works together with filter bundle
- inheritable list configurations
- template are build in twig
- support for Encore Bundle
Usage
Install
- Install via composer (
composer require heimrichhannot/contao-list-bundle
) or contao manager - Update your database
Recommendations:
- use this bundle together with Reader Bundle.
- use Encore Bundle for managing your frontend assets
Usage
HINT: You can do the following steps for a basic list setup also in an interactive command. Simply run
vendor/bin/contao-console huh-list:make
in your contao root.
- Setup a filter (see Filter Bundle setup)
- Create a list config (System -> List config)
- To add list elements like images, videos, slider etc, add list config elements (see Concepts -> List config elements for explanation)
- Recommendation: for better performance, check "Limit formatted fields" in your list configuration and select only the fields you really need to have formatted
- Create a list frontend module and output it, where you like it
Concepts
Inheritable list configuration
Since list configuration can be lots of data sometimes we decided to outsource it into a dedicated DCA entity. These entities can be assigned to one or even multiple list modules in a reusable way.
In addition it's possible to create list configs that inherit from other list configs. Hence overriding a single option while keeping everything else is possible.
The Item class
Every database record output in a list (e.g. an event) is modelled and wrapped by the Item
class. The concrete class is DefaultItem
. You can imagine
the item as a kind of ORM (object-relational-mapping).
The most important properties of an item are the arrays raw
and formatted
which also can be iterated in the list item template:
raw
: contains the raw database valuesformatted
: contains the formatted representation of the raw values
Example: Let's say a database record has a field startDate
which holds a unix timestamp of the date chosen in the backend.
Then raw
contains this unix timestamp and formatted
contains the pretty printed date according to the dateFormat
set in
the contao settings, i.e. "2020-09-12".
The list bundle uses the method FormUtil::prepareSpecialValueForOutput()
in heimrichhannot/contao-utils-bundle
for handling special values. It supports a wide range of types of special values:
- date/time fields
- arrays
- fields with
options
,options_callback
and entries in the DCA'sreference
key - binary fields (files, images, ...)
- ...
You can access both of these arrays in your list item twig template as you normally would in twig:
{% for field, value in raw %} {% endfor %} {% for field, value in formatted %} {% endfor %}
CAUTION: By default all values of a database record are formatted and accessible in the item template. As you can imagine
if some of the fields have thousands of options, the process of formatting can take some time and can reduce the peformance
of your website. Hence you always should limit the formatted fields and only format these you really need. You can adjust that
in the list configuration (field limitFormattedFields
).
For convenience reasons you can also access the field values like so in your twig template:
{{ fieldname }}
If you configured the field fieldname
to be formatted, it will contain the formatted value. If not, the raw one. If
it's formatted, you can still access its raw value by using:
{{ raw.fieldname }}
List config elements
Every list config can have one or more list config elements. These are designed to specify things that can occur multiple times (e.g. because there are many fields of one type).
Currently available list config element types:
Image
You can add images either as formatted value of, if you also like to have additional features like image size processing or automatic placeholders if no image is set, you can use the image list config element.
After the configuration you can output it as follows in your item template:
{% if images|default and images.myImage|default %} {{ include('@HeimrichHannotContaoUtils/image.html.twig', images.myImage) }} {% endif %}
IMPORTANT: Note that by default the generated picture elements are added to an array called images
. If your DCA
contains a field with the same name, you need to specify a different container name like e.g. resizedImages
(using overrideTemplateContainerVariable
).