我有一个基础扩展程序,可以对我的网站进行版本控制。这意味着我在扩展程序中没有控制器或存储库。因此,我想做的是在现有元素上创建自己的设置。我试验了一下标题内容元素的文本对齐值。
请注意,已经有一个此设置,但我只是在尝试实验。
我找到了如何添加它们,并且这些值已保存在数据库中。
我现在想做的是将这些值作为FLUID类添加。这就是我卡住的地方。我无法获取这些值。有没有什么办法可以做到?
在阅读了如何在TYPO3 7.6中启用header_position后,我设法把我的代码写到了这个程度:
在文件夹/Configuration/TCA/Overrides/tt_content.php中:
在文件夹/Configuration/Typoscript/Constants/Base.typoscript中
在 /Resources/Private/Extensions/Fluid_styled_content/Resourcs/Private/Partials/Header.html 中。
我将翻译为:
我成功地将选择框放在了我想要的位置,并且将值保存到了数据库中。这意味着,如果我在选择框中选择“Center”这个值,那么它将被保存到数据库中。我该如何获取这个值并在FLUID中使用它作为类?
提前感谢您的帮助。
请注意,已经有一个此设置,但我只是在尝试实验。
我找到了如何添加它们,并且这些值已保存在数据库中。
我现在想做的是将这些值作为FLUID类添加。这就是我卡住的地方。我无法获取这些值。有没有什么办法可以做到?
在阅读了如何在TYPO3 7.6中启用header_position后,我设法把我的代码写到了这个程度:
在文件夹/Configuration/TCA/Overrides/tt_content.php中:
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
ExtensionManagementUtility::addTCAcolumns('tt_content',[
'header_position_custom' => [
'exclude' => 1,
'label' => 'header position',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['left', 'left'],
['right', 'right'],
['center', 'center']
]
]
]
]);
ExtensionManagementUtility::addFieldsToPalette('tt_content', 'header', '--linebreak--,header_position_custom', 'after:header_layout');
ExtensionManagementUtility::addFieldsToPalette('tt_content', 'headers', '--linebreak--,header_position_custom', 'after:header_layout');
在文件夹/Configuration/Typoscript/Constants/Base.typoscript中
styles.templates.templateRootPath = EXT:my_website_base/Resources/Private/Extensions/Fluid_styled_content/Resources/Private/Templates/
styles.templates.partialRootPath = EXT:my_website_base/Resources/Private/Extensions/Fluid_styled_content/Resources/Private/Partials/
styles.templates.layoutRootPath = EXT:my_website_base/Resources/Private/Extensions/Fluid_styled_content/Resources/Private/Layouts/
在 /Resources/Private/Extensions/Fluid_styled_content/Resourcs/Private/Partials/Header.html 中。
<h1 class="{positionClass} {header_position_custom} {data.header_position_custom} showed">
<f:link.typolink parameter="{link}">{header}</f:link.typolink>
</h1>
我将翻译为:
我只是展示了这个类,以确保我正在从常量给出的路径读取文件。
文件 ext_tables.php
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY,'Configuration/TypoScript', 'Website Base');
文件 ext_tables.sql
CREATE TABLE tt_content (
header_position_custom varchar(255) DEFAULT '' NOT NULL,
);
我成功地将选择框放在了我想要的位置,并且将值保存到了数据库中。这意味着,如果我在选择框中选择“Center”这个值,那么它将被保存到数据库中。我该如何获取这个值并在FLUID中使用它作为类?
提前感谢您的帮助。
{_all}
,则您的对象根本无法呈现。请确保从基类继承并为字段添加getter和setter。 - Bernd Wilke πφext:extension_builder
来构建一个扩展的原型,该扩展仅向现有记录(例如 tt_content)添加一个字段。请查看声明和继承。 - Bernd Wilke πφ