ameotoko / contao-dc-sortable
Contao 5 DataContainer driver with drag'n'drop sorting support
Installs: 21
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:contao-bundle
Requires
- php: ^8.1
- contao/core-bundle: ^5.2
- symfony/config: ^6.3
- symfony/dependency-injection: ^6.3
- symfony/http-kernel: ^6.3
Requires (Dev)
- contao/manager-plugin: ^2.3.1
Conflicts
- contao/manager-plugin: <2.0 || >=3.0
README
A DataContainer driver for Contao 5 CMS, that extends core DC_Table
driver
with custom "drag'n'drop" sorting capability.
Install
composer require ameotoko/contao-dc-sortable
Use in your data container
This is a minimal DCA configuration to make it work:
// tl_custom.php use Ameotoko\DCSortableBundle\DataContainer\DC_TableSortable; $GLOBALS['TL_DCA']['tl_custom'] = [ 'config' => [ 'dataContainer' => DC_TableSortable::class, // enable the driver ], 'list' => [ 'sorting' => [ 'mode' => DataContainer::MODE_SORTED, // this mode is required 'flag' => DataContainer::SORT_ASC, 'fields' => ['sorting'] // drag'n'drop table must be sorted by the "sorting" field ], 'label' => [ // Contao will force the first sorting field to appear as a column in backend list view. // You can prevent this using this setting (requires Contao 5.2.8 or later). 'showFirstOrderBy' => false ], // add the drag handle 'operations' => [..., 'drag' => [ 'icon' => 'drag.svg', 'attributes' => 'class="drag-handle" aria-hidden="true"', 'button_callback' => static function ($row, $href, $label, $title, $icon, $attributes) { return \Contao\Image::getHtml($icon, $label, $attributes); } ]] ], // add required fields 'fields' => [ 'id' => [ 'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'autoincrement' => true], 'search' => true ], 'sorting' => [ 'sql' => ['type' => Types::INTEGER, 'unsigned' => true, 'default' => 0] ], ]