heimrichhannot/contao-archive-palettes-bundle

该组件为Contao CMS后端根据父级归档选择自定义调色板的功能提供支持。

1.2.0 2023-07-17 14:54 UTC

This package is auto-updated.

Last update: 2024-09-17 17:07:29 UTC


README

该组件为Contao CMS后端根据父级归档选择自定义调色板的功能提供支持。

特性

  • 将自定义调色板添加到您的DCA文件中
  • 在父级归档中选择它们

安装

  1. 使用composer安装: composer require heimrichhannot/contao-archive-palettes-bundle

  2. 调整您的项目配置

    tl_news 示例

    # config/config.yml
    huh_archive_palettes:
      tables:
         tl_news: # The table where the custom palettes should be applied
            parent: "tl_news_archive" # The archive table where custom palette should be selected
            palette_parent: "comments_legend" # A legend or a field after which the palette selector should be inserted in the parent table palette
  3. 清除缓存并更新您的数据库

配置

通过yaml进行配置

# Default configuration for extension with alias: "huh_archive_palettes"
huh_archive_palettes:

   # The tables that should be extended with the archive palette.
   tables:               # Example: tl_news

      # Prototype
      name:

         # The parent (archive) table.
         parent:               ~ # Required, Example: tl_news_archive

         # A field or a parent where the should be added after.
         palette_parent:       ~ # Required

通过PHP进行配置

  1. 打开您想要扩展的DCA文件。以tl_news为例,它应位于您的项目组件中。
  2. 按常规创建自定义字段调色板
    // ...
    $dca['palettes']['custom_palette1'] = '{general_legend},field1,field2;';
    $dca['palettes']['custom_palette2'] = '{general_legend},field3,field4;';
  3. 将以下代码粘贴到DCA文件的末尾,以便插入调色板操作逻辑
    System::getContainer()->get(\HeimrichHannot\ArchivePalettesBundle\Manager\ArchivePalettesManager::class)->addArchivePalettesSupportForChild(
        'tl_news', 'tl_news_archive'
    );
  4. 打开父级 DCA文件,即归档DCA文件。对于tl_news,这将是以tl_news_archive
  5. 将以下代码粘贴到DCA文件的末尾,以便插入调色板操作逻辑
    System::getContainer()->get(\HeimrichHannot\ArchivePalettesBundle\Manager\ArchivePalettesManager::class)->addArchivePalettesSupportForArchive(
        'tl_news', 'tl_news_archive'
    );
  6. 将以下代码添加到文件末尾,以便添加调色板选择字段(字段已在之前的步骤中添加)
    // ...
    $dca['palettes']['default'] = $dca['palettes']['default'] . ';{archive_palettes_legend},addArchivePalette;';
  7. 清除项目缓存并更新数据库以添加所需字段。
  8. 打开归档的配置(通常是editheader操作)并根据您的需要设置自定义调色板。