heimrichhannot / contao-archive-palettes-bundle
该组件为Contao CMS后端根据父级归档选择自定义调色板的功能提供支持。
1.2.0
2023-07-17 14:54 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.9
- heimrichhannot/contao-utils-bundle: ^2.164
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/polyfill-php80: ^1.26
README
该组件为Contao CMS后端根据父级归档选择自定义调色板的功能提供支持。
特性
- 将自定义调色板添加到您的DCA文件中
- 在父级归档中选择它们
安装
-
使用composer安装:
composer require heimrichhannot/contao-archive-palettes-bundle
。 -
调整您的项目配置
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
-
清除缓存并更新您的数据库
配置
通过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进行配置
- 打开您想要扩展的DCA文件。以
tl_news
为例,它应位于您的项目组件中。 - 按常规创建自定义字段调色板
// ... $dca['palettes']['custom_palette1'] = '{general_legend},field1,field2;'; $dca['palettes']['custom_palette2'] = '{general_legend},field3,field4;';
- 将以下代码粘贴到DCA文件的末尾,以便插入调色板操作逻辑
System::getContainer()->get(\HeimrichHannot\ArchivePalettesBundle\Manager\ArchivePalettesManager::class)->addArchivePalettesSupportForChild( 'tl_news', 'tl_news_archive' );
- 打开父级 DCA文件,即归档DCA文件。对于
tl_news
,这将是以tl_news_archive
。 - 将以下代码粘贴到DCA文件的末尾,以便插入调色板操作逻辑
System::getContainer()->get(\HeimrichHannot\ArchivePalettesBundle\Manager\ArchivePalettesManager::class)->addArchivePalettesSupportForArchive( 'tl_news', 'tl_news_archive' );
- 将以下代码添加到文件末尾,以便添加调色板选择字段(字段已在之前的步骤中添加)
// ... $dca['palettes']['default'] = $dca['palettes']['default'] . ';{archive_palettes_legend},addArchivePalette;';
- 清除项目缓存并更新数据库以添加所需字段。
- 打开归档的配置(通常是
editheader
操作)并根据您的需要设置自定义调色板。