[英]TYPO3 TCA value as a variable on 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上的類?
提前致謝,
您將在data
對象中找到您的字段。
要檢查流體變量,可以使用f:debug
-VH:
<f:debug title="the data">{data}</f:debug>
要檢查所有(在當前上下文中)可用變量,可以調試_all
:
<f:debug title="all data">{_all}</f:debug>
提示:使用title
屬性來標識輸出
並且不要忘記為新字段編寫get*
和set*
函數!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.