ichhabrecht / t3tags
为每种记录类型生成标签字段
1.0.1
2020-09-30 11:11 UTC
Requires
- php: >= 7.0, < 7.4
- typo3/cms-core: ^8.7 || ^9.5
Requires (Dev)
- nimut/testing-framework: 4.x-dev
Replaces
- typo3-ter/t3tags: 1.0.1
This package is auto-updated.
Last update: 2024-09-06 06:05:12 UTC
README
为每种记录类型生成标签字段。
功能
- 集成到核心API并扩展
group
字段行为 - 新标签可以动态添加,并且只有当记录被保存时才会创建
- 添加到多个(标签)字段的新标签只在数据库中创建一次
安装
- 只需使用Composer或扩展管理器安装扩展。
composer require ichhabrecht/t3tags
- 在扩展设置中配置一个页面UID,其中标签应被存储。
使用方法
使用TagRegistry注册新字段
- 在Configuration/TCA/Overrides中添加或扩展文件
<?php
defined('TYPO3_MODE') || die();
(function () {
$tagRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\IchHabRecht\T3tags\Configuration\TagRegistry::class);
$tagRegistry->makeTaggable(
'tt_content',
'relevant_tags',
[
'label' => 'Relevant tags',
'position' => 'after:--palette--;;access',
'fieldConfiguration' => [
'maxitems' => 5,
'fieldInformation' => [
'tagInformation' => [
'options' => [
'labels' => [
0 => [
'label' => 'Add here up to five super relevant tags',
],
],
],
],
],
],
]
);
$tagRegistry->makeTaggable(
'tt_content',
'content_tags',
[
'label' => 'Content tags',
'position' => 'after:relevant_tags',
'fieldConfiguration' => [
'fieldInformation' => [
'tagInformation' => [
'options' => [
'labels' => [
0 => [
'label' => 'Add here unlimited content tags that describe your topic and the content detail',
],
],
],
],
],
],
]
);
})();
参数
- 表名:应扩展的现有TCA表
- 字段名:要添加的新标签字段名称
- 选项:根据TCA字段配置的附加字段配置
- 标签
- 排除
- fieldConfiguration (config)
- l10n_display
- l10n_mode
- displayCond
- 位置
- 接口
- fieldList
- typesList
- 覆盖:如果应使用提供的配置替换任何现有字段配置,则设置为True
通过字段获取所有标签
$tagRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\IchHabRecht\T3tags\Domain\Repository\TagRepository::class);
$tagRepository->findTagsByField('tt_content', 'relevant_tags', 42);
- 从UID为
42
的tt_content
元素及其字段relevant_tags
获取所有标签(作为数组)
通过记录获取所有标签
$tagRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\IchHabRecht\T3tags\Domain\Repository\TagRepository::class);
$tagRepository->findTagsByRecord('tt_content', 42);
- 从UID为
42
的tt_content
元素获取所有标签(作为数组)。根据上面的示例注册,返回relevant_tags
和content_tags
中的标签。