在 TYPO3 6.2 中添加自定义页面属性字段的推荐方法是什么?
在 4.5 中,我使用了 TemplaVoila,它有自己的页面模块,可以很容易地在页面级别添加数据记录。
2 回答
有几种方法:
- “香草”方法:
创建一个扩展(以及它的文件ext_emconf.php
),然后ext_tables.sql
在扩展根目录中创建一个文件。CREATE TABLE
通过为 pages 表定义一个语句,您可以在其中放置新字段的 SQL 定义:
CREATE TABLE pages(
myNewField int(11) DEFAULT '',
);
此 SQL 定义将与 table 的现有定义合并page
。
然后您需要在Table Configuration Array (TCA)中配置新字段。您通常可以在现有扩展中找到很好的示例,例如在realurl
. 有两个地方可以将这些定义放在文件中ext_tables.php
(未缓存)或文件夹中的 php 文件中Configuration/Tca/Overrides
(缓存)。
这种方法听起来比实际工作更多。
只需使用 TemplaVoila。它适用于 TYPO3 6.2,但它的未来是不确定的,AFAIK。
使用扩展的fluidtypo3-生态系统,尤其是扩展
fluidpages
。它做你想做的事,与 TemplaVoila 类似,但采用现代(= 基于流体)技术。
如果您需要自己的自定义内容元素,我推荐扩展“DCE”(动态内容元素)。
DCE 非常容易定制,您可以在几分钟内创建内容元素。
你也可以像约斯特说的那样做。使用自己的扩展名并将 TCA 定义放在您的 extTables.php 中
例如:
/www/htdocs/website/typo3conf/ext/custom_extension/ext_tables.php
$tmp_itm_extended_columns_pages = array(
'link_class' => array(
'exclude' => 0,
'label' => 'LLL:EXT:itm_extended/Resources/Private/Language/locallang_db.xlf:label.linkClass',
'config' => array(
'type' => 'select',
'items' => array(
array('Nichts', ''),
array('Zahnrad', 'icon-afford', 'EXT:custom_extension/Resources/Public/img/icons/icon_preferences_small.png'),
array('Fabrik', 'icon-factory', 'EXT:custom_extension/Resources/Public/img/icons/icon_factory_small.png'),
array('Computer', 'icon-software', 'EXT:custom_extension/Resources/Public/img/icons/icon_software_small.png'),
array('Person', 'icon-jobs', 'EXT:custom_extension/Resources/Public/img/icons/icon_person_small.png'),
array('Welt', 'icon-world', 'EXT:custom_extension/Resources/Public/img/icons/icon_world_small.png'),
array('Rohre', 'icon-pipe', 'EXT:custom_extension/Resources/Public/img/icons/icon_pipe_small.png'),
),
),
),
);
然后你必须将你的新字段添加到 ext_tables.sql
#
# Table structure for table 'pages'
#
CREATE TABLE pages (
link_class text
);