ameotoko / contao-dc-sortable
支持拖放排序的 Contao 5 DataContainer 驱动程序
1.0.1
2024-02-10 17:57 UTC
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
这是 Contao 5 CMS 的 DataContainer 驱动程序,它扩展了核心 DC_Table
驱动程序,增加了自定义的 "拖放排序" 功能。
安装
composer require ameotoko/contao-dc-sortable
在数据容器中使用
这是使它工作所需的最小 DCA 配置
// 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] ], ]