我有一个基本扩展,所以我可以版本我的网站 . 这意味着我没有扩展控制器或存储库 . 所以我想做的是在现有元素上创建自己的设置 . 我正在试验 Headers 内容元素上的文本对齐值 .
请记住,已有一个设置,但我只是在试验 .
我想出了如何添加它们,并将值保存在数据库中 .
我现在想要做的是获取值并将它们添加为FLUID上的类 . 这是我卡住的地方 . 我无法得到这些 Value 观 . 知道怎么做吗?
在本指南之后How to enable header_position in TYPO3 7.6我设法得到我的代码:
On the folder /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');
On the folder /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/
On the /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>
我已经把这个类显示出来,以确保我从常量的路径上读取文件
File ext_tables.php
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY,'Configuration/TypoScript', 'Website Base');
File ext_tables.sql
CREATE TABLE tt_content (
header_position_custom varchar(255) DEFAULT '' NOT NULL,
);
有了所有这些,我得到我想要的选择框,我得到数据库上的值 . 这意味着如果我在选择框中选择值“中心”,那么它将保存在数据库中 . 如何获得此值并将其用作FLUID上的类?
提前致谢,
1 回答
您将在
data
对象中找到您的字段 .要检查流体变量,可以使用
f:debug
-VH:检查所有(在当前上下文中)可用变量,您可以调试
_all
:Hint: 使用
title
属性来标识输出and don't forget to write a get and set function for new fields!**