typo3-9.x - 在“文件/链接上传”中添加新字段 tt_content
问题描述
我使用File Links [uploads]
Content Element 来显示文件列表,我需要在这个 CE 上添加一个字段来显示描述。
我在文档中找到了这个:https ://docs.typo3.org/m/typo3/reference-coreapi/8.7/en-us/ExtensionArchitecture/ExtendingTca/Examples/#example-2-extending-the-tt-content-表,但由于缺乏 PHP 和 T3 自定义技能,我无法应用它。
我应该在哪个文件中添加以下代码:
CREATE TABLE tt_content (
tx_files_description tinyint(4) DEFAULT '0' NOT NULL
);
如何自定义以下代码?:
$temporaryColumn = array(
'tx_files_description' => array (
'exclude' => 0,
'label' =>
'LLL:EXT:examples/Resources/Private/Language/locallang_db.xlf:tt_content.tx_files_description',
'config' => array (
'type' => 'check',
)
)
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
$temporaryColumn
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'visibility',
'tx_files_description',
'after:linkToTop'
);
解决方案
Since you created your own content element i can not really know how to position the lement, but what i can do is to help you create it. I just tested on my TYPO3 installtion and it works.
ext_tables.sql
CREATE TABLE tt_content (
tx_files_description text,
);
yourExtension/Configuration/TCA/Overrides/tt_content.php
$temporaryColumn = [
'tx_files_description' => [
'exclude' => true,
'label' => 'LLL:EXT:your_extension_key/Resources/Private/Language/locallang.xlf:tt_content.tx_files_description',
'config' => [
'type' => 'text',
'enableRichtext' => false,
],
],
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
$temporaryColumn
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'tx_files_description',
'general',
'before:media'
);
Assuming that you re using TYPO3 v9 go to the module Maintenance and press Analyze Database, then clear all cache.
If you are on TYPO3 v7-v8 then go to the install module and Run compare database (something like that). Clear the cache.
Then on your extended tab:
Best regards
推荐阅读
- mysql - 错误代码:2013。在使用运算符查询期间丢失与 MySQL 服务器的连接 - 或
- r - 通过 R 中的多个变量对纵向数据集进行子集化
- tsql - 报告后面的 SQL 发生了变化,但返回的记录集没有,这是一个问题吗?
- google-apps-script - GOOGLE BUSINESS - 如何为我的网站设置网站图标?
- graph - 通过在简化图中查找模式来计算 ARI
- python - Jupyter:内核似乎已经死了。它会自动重启
- hyperledger-fabric - 超级账本结构设计
- java - Mockito.invokeMethod:我可以将功能接口的实现作为参数传递吗?
- c# - c# regex 只获取字符串中的负数
- azure - Azure Kudu 在 2.2.1 sdk 发布后无法恢复包