heimrichhannot/contao-entity-filter-bundle

本模块提供了一种输入类型,可以通过舒适地“点击”类似SQL的条件来选择一个或多个实体。

1.11.0-beta1 2024-03-05 09:35 UTC

This package is auto-updated.

Last update: 2024-09-12 17:44:12 UTC


README

本模块提供了一种输入类型,可以通过舒适地“点击”类似SQL的条件来选择一个或多个实体。

alt text

功能

  • “点击”条件进行过滤(即选择)任意contao实体
  • 从其他记录加载现有的过滤条件
  • 在contao记录的编辑视图中直接显示过滤结果列表

技术说明

本模块提供了3种舒适的函数,可以将前面提到的小部件直接添加到您的dca中。

注意:当然,如果您不希望这3个函数符合您的需求,您也可以复制它们并自定义它们。

将实体过滤小部件添加到您的dca中

提示:如果您希望动态设置要过滤的表,您可以在onload_callback中这样做。但您仍然需要在您的dca中调用以下函数,而不是回调,否则exclude将不会被正确设置。

\Contao\System::getContainer()->get('huh.entity_filter.manager')->addFilterToDca(
    // the name of the field
    'memberConditions',
    // your dca
    'tl_md_recipient_list',
    // the table to be filtered
    'tl_member'
);

添加一个字段以从其他记录复制实体过滤器

\Contao\System::getContainer()->get('huh.entity_filter.manager')->addFilterCopierToDca(
    // the name of the field
    'filterCopier',
    // your dca
    'tl_recipient_list',
    // the dca where the field values are situated you want to copy (usually the same as your dca)
    'tl_recipient_list',
    // the entity_filter field
    'memberConditions',
    // a custom options_callback -> if left out, ['huh.field_value_copier.util.field_value_copier_util', 'getOptions'] is used
    ['huh.field_value_copier.util.field_value_copier_util', 'getOptions'],
    // config parameters for field value copier widget
    [
        'labelPattern' => '%title% (ID %id%)'
    ]
);

添加一个实时重新加载的表来显示您条件的结果

\Contao\System::getContainer()->get('huh.entity_filter.manager')->addListToDca(
    // the name of the field
    'memberList',
    // your dca
    'tl_recipient_list',
    // the entity_filter field
    'memberConditions',
    // the table being filtered
    'tl_member',
    // the header fields of the table
    array(
        'title',
        'firstname',
        'lastname',
        'email',
    )
);

事件