Download the PHP package heimrichhannot/contao-list-widget-bundle without Composer
On this page you can find all versions of the php package heimrichhannot/contao-list-widget-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download heimrichhannot/contao-list-widget-bundle
More information about heimrichhannot/contao-list-widget-bundle
Files in heimrichhannot/contao-list-widget-bundle
Package contao-list-widget-bundle
Short Description This bundle offers an input type for displaying a list of entities definable by a callback function.
License LGPL-3.0-or-later
Homepage https://github.com/heimrichhannot/contao-list-widget-bundle
Informations about the package contao-list-widget-bundle
Contao List Widget
This bundle offers functionality for displaying a list in the Contao backend (either as a dca field or in a backend module).
For visualization the javascript library DataTables is used.
Features
- inputType "listWidget" for usage as a dca field
- convenient functions for integrating a list in your backend module
- the list can display either model data or even arbitrary arrays
- support for datatables javascript library
- filter the table
- search the table
- sort the table
- support for ajax reloading data using datatables -> currently only working for contao models since SQL-commands like LIMIT are used
Technical instructions
Usage as a widget in a dca field
Use the inputType "listWidget" for your field.
Usage in a module
Add the following code e.g. in the generate() method of your BackendModule:
Call this in your module's compile method:
Copy the content of list_widget.html5 into your module's template.
Using ajax with custom routes
Since version 1.3 it is possible to use custom routes for ajax requests to have more control or freedom over the returned data.
Use ListWidgetContext
class as helper to process the request and return a ListWidgetResponse
object.
Example load_items_callback
Here you can see an example for overriding the core behavior of loadItems():
Config (same structure for DCA -> eval -> listWidget and shortcut functions)
Name | Possible value | Description |
---|---|---|
identifier | string | Needed for distinguishing requests from multiple list widget implementations, e.g. |
header_fields | array | Must return an array containing the header fields. The keys must match the keys of the arrays/objects in items/items_callback. |
header_fields_callback | callback array, function closure | Must return an array containing the header fields. The keys must match the keys of the arrays/objects in items/items_callback. |
items | array | Must return an array containing the items to be displayed. The item keys must match those in header_fields/header_fields_callback. |
items_callback | callback array, function closure | Must return an array containing the items to be displayed. The item keys must match those in header_fields/header_fields_callback. |
table | string (e.g. "tl_dca") | This value is needed for useDbAsHeader and ajax handling |
useDbAsHeader | boolean | Set to true if the header should contain all fields of a certain database entity ("table" is used) |
template | string | Specify a custom template |
language | array | Specify custom localizations (see ListWidget::getLanguage() for details) |
language_callback | callback array, function closure | Specify custom localizations (see ListWidget::getLanguage() for details) |
ajax | boolean | Set to true if ajax reloading should take place (no need for items_callback in this case) |
ajaxConfig -> load_items | array | Override this if custom model options or methods are needed (see ListWidget::loadItems() for details) |
ajaxConfig -> load_items_callback | callback array, function closure | Override this if custom model options or methods are needed (see ListWidget::loadItems() for details) |
ajaxConfig -> prepare_items | array | Override this if custom data preparation is needed (see ListWidget::prepareItems() for details) |
ajaxConfig -> prepare_items_callback | callback array, function closure | Override this if custom data preparation is needed (see ListWidget::prepareItems() for details) |
Callbacks
Name | Arguments | Expected return value | Description |
---|---|---|---|
headerFields_callback | $objDc, $arrDca, $objWidget | array containing field and label pairs () | This callback must return the headerFields to be displayed in the list. Array keys need to be the keys in items_callback (see list_widget.html5 for explanation). |
items_callback | $objDc, $arrDca, $objWidget | array of entity arrays () | This callback must return the items to be displayed in the list |
load_callback | $arrOptions, [], $objDc, $arrDca, $objWidget | data array (see ListWidget::loadItems for more details) | Override this method if custom model options or methods are needed |
prepare_items_callback | $objItems, $arrListOptions, $arrOptions, $objDc, $arrDca, $objWidget | data array (see ListWidget::prepareItems for more details) | Override this method if custom data preparation is needed |
All versions of contao-list-widget-bundle with dependencies
ext-json Version *
ausi/slug-generator Version ^1.0
contao/core-bundle Version ^4.13
heimrichhannot/contao-ajax-bundle Version ~1.0
heimrichhannot/contao-request-bundle Version ^1.1.1
heimrichhannot/contao-utils-bundle Version ^2.225
heimrichhannot/datatables Version ^1.10
heimrichhannot/datatables-additional Version ^1.0
symfony/http-foundation Version ^5.4 || ^6.4 || ^7.0
symfony/http-kernel Version ^5.4 || ^6.4 || ^7.0