不呈现自定义内容元素的 TYPO3 8.7 后端字段
TYPO3 8.7 Backend fields for a custom content element are not rendered
我在 TYPO3 8.7 上有一个模板扩展,并尝试添加一些自定义内容元素。一切似乎都工作正常,除了后端字段 - 它们只是没有呈现。
我从头开始开发扩展,并认为这可能是问题所在,所以我安装了 Extension Builder 模块并用它做了另一个扩展,但结果还是一样。
扩展结构:
├── Classes
│ ├── Controller
│ └── Domain
│ ├── Model
│ │ └── Basic.php
│ └── Repository
│ └── BasicRepository.php
├── Configuration
│ ├── ExtensionBuilder
│ │ └── settings.yaml
│ ├── PageTSconfig
│ │ └── tsconfig.txt
│ ├── TCA
│ │ ├── Overrides
│ │ │ ├── pages.php
│ │ │ └── tt_content.php
│ │ └── tx_mytest_domain_model_basic.php
│ └── Typoscript
│ ├── contsants.typoscript
│ └── setup.typoscript
├── Documentation.tmpl
├── ExtensionBuilder.json
├── Resources
│ ├── Private
│ │ ├── Language
│ │ │ ├── Tca.xlf
│ │ │ ├── locallang.xlf
│ │ │ └── locallang_db.xlf
│ │ ├── Layouts
│ │ │ ├── Default.html
│ │ │ └── Page.html
│ │ ├── Partials
│ │ │ ├── Assets.html
│ │ │ ├── Footer.html
│ │ │ ├── Header.html
│ │ │ ├── SearchBox.html
│ │ │ └── Sidebar.html
│ │ └── Templates
│ │ ├── Content
│ │ │ ├── Counter.html
│ │ │ └── Slider.html
│ │ └── Page
│ │ └── Default.html
│ └── Public
│ ├── Icons
│ │ ├── blue.png
│ │ ├── relation.gif
│ │ └── tx_mytest_domain_model_basic.gif
│ └── assets -> ../../../../../../templates/project/app/assets
├── Tests
├── composer.json
├── ext_emconf.php
├── ext_localconf.php
├── ext_tables.php
└── ext_tables.sql
ext_localconf.php:
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon('content-icon',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
['source' => 'EXT:my_test/Resources/Public/icons/blue.png']);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'mod.wizards.newContentElement.wizardItems.Test {
header = Test
elements {
slider {
iconIdentifier = content-icon
title = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_slider.wizard.title
description = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_slider.wizard.description
tt_content_defValues {
CType = slider
}
}
counter {
iconIdentifier = content-icon
title = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_counter.wizard.title
description = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_counter.wizard.description
tt_content_defValues {
CType = counter
}
}
}
show := addToList(*)
}'
);
ext_tables.php:
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function()
{
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('my_test', 'Configuration/TypoScript', 'Test');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_mytest_domain_model_basic', 'EXT:my_test/Resources/Private/Language/locallang_csh_tx_mytest_domain_model_basic.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_mytest_domain_model_basic');
}
setup.typoscript:
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_styled_content/Configuration/TypoScript/setup.txt">
page = PAGE
page {
typeNum = 0
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
key.data = pagelayout
pagets__site_package_default = TEXT
pagets__site_package_default.value = Default
default = TEXT
default.value = Default
}
templateRootPaths {
0 = EXT:my_test/Resources/Private/Templates/Page/
1 = {$page.fluidtemplate.templateRootPath}
}
partialRootPaths {
0 = EXT:my_test/Resources/Private/Partials/
1 = {$page.fluidtemplate.partialRootPath}
}
layoutRootPaths {
0 = EXT:my_test/Resources/Private/Layouts/
1 = {$page.fluidtemplate.layoutRootPath}
}
}
}
lib.contentElement {
templateRootPaths {
20 = EXT:my_test/Resources/Private/Templates/Content/
}
}
tt_content.counter =< lib.contentElement
tt_content.counter {
templateName = Counter
}
tt_content.slider =< lib.contentElement
tt_content.slider {
templateName = Slider
}
);
TCA/Overrides/tt_content.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_slider',
'slider',
'EXT:my_test/Resources/Public/icons/blue.png'
),
'CType',
'Myext'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_counter',
'counter',
'EXT:my_test/Resources/Public/icons/blue.png'
),
'CType',
'Myext'
);
Templates/Content/Counter.html:
<html xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers" flux:schemaLocation="http://fluidtypo3.org/schemas/flux-development.xsd"
xmlns:fcc="http://typo3.org/ns/FluidTYPO3/FluidcontentCore/ViewHelpers" fcc:schemaLocation="http://fluidtypo3.org/schemas/fluidcontent_core-development.xsd"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" v:schemaLocation="http://fluidtypo3.org/schemas/vhs-development.xsd"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" f:schemaLocation="http://fluidtypo3.org/schemas/fluid-master.xsd">
<f:layout name="Default"/>
<f:section name="Configuration">
<flux:form id="counter"
label="counter"
description="Counter description">
<flux:form.option.icon value="EXT:my_test/Resources/Public/icons/blue.png"/>
<flux:form.option.group value="Test" />
<flux:form.section name="counters" label="Counter">
<flux:form.object name="item" label="Counter item">
<flux:field.input name="title" label="Counter title" placeholder="Counter title" required="true" />
</flux:form.object>
</flux:form.section>
</flux:form>
</f:section>
<f:section name="Preview"></f:section>
<f:section name="Main">
<h1>Counter check!</h1>
</f:section>
</html>
该元素可以在向导中看到并在前端呈现,但是当我想在后端编辑它时,它没有后端字段,除了带有元素类型的下拉列表。我想我没有添加一些配置来让它工作,但我不知道它可能是什么。
我解决了这个问题。 ext_localconf.php 中缺少以下行:
\FluidTYPO3\Flux\Core::registerProviderExtensionKey('MyTest.my_test', 'Content');
那么我不需要tt_content.php中的代码,因为它添加到下拉列表的项目与后端布局无关。新的内容元素会自动从模板文件添加到下拉列表中,并使用以下信息:
<flux:form id="counter"
label="counter"
description="Counter description">
我在 TYPO3 8.7 上有一个模板扩展,并尝试添加一些自定义内容元素。一切似乎都工作正常,除了后端字段 - 它们只是没有呈现。
我从头开始开发扩展,并认为这可能是问题所在,所以我安装了 Extension Builder 模块并用它做了另一个扩展,但结果还是一样。
扩展结构:
├── Classes
│ ├── Controller
│ └── Domain
│ ├── Model
│ │ └── Basic.php
│ └── Repository
│ └── BasicRepository.php
├── Configuration
│ ├── ExtensionBuilder
│ │ └── settings.yaml
│ ├── PageTSconfig
│ │ └── tsconfig.txt
│ ├── TCA
│ │ ├── Overrides
│ │ │ ├── pages.php
│ │ │ └── tt_content.php
│ │ └── tx_mytest_domain_model_basic.php
│ └── Typoscript
│ ├── contsants.typoscript
│ └── setup.typoscript
├── Documentation.tmpl
├── ExtensionBuilder.json
├── Resources
│ ├── Private
│ │ ├── Language
│ │ │ ├── Tca.xlf
│ │ │ ├── locallang.xlf
│ │ │ └── locallang_db.xlf
│ │ ├── Layouts
│ │ │ ├── Default.html
│ │ │ └── Page.html
│ │ ├── Partials
│ │ │ ├── Assets.html
│ │ │ ├── Footer.html
│ │ │ ├── Header.html
│ │ │ ├── SearchBox.html
│ │ │ └── Sidebar.html
│ │ └── Templates
│ │ ├── Content
│ │ │ ├── Counter.html
│ │ │ └── Slider.html
│ │ └── Page
│ │ └── Default.html
│ └── Public
│ ├── Icons
│ │ ├── blue.png
│ │ ├── relation.gif
│ │ └── tx_mytest_domain_model_basic.gif
│ └── assets -> ../../../../../../templates/project/app/assets
├── Tests
├── composer.json
├── ext_emconf.php
├── ext_localconf.php
├── ext_tables.php
└── ext_tables.sql
ext_localconf.php:
$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class);
$iconRegistry->registerIcon('content-icon',
\TYPO3\CMS\Core\Imaging\IconProvider\BitmapIconProvider::class,
['source' => 'EXT:my_test/Resources/Public/icons/blue.png']);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(
'mod.wizards.newContentElement.wizardItems.Test {
header = Test
elements {
slider {
iconIdentifier = content-icon
title = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_slider.wizard.title
description = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_slider.wizard.description
tt_content_defValues {
CType = slider
}
}
counter {
iconIdentifier = content-icon
title = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_counter.wizard.title
description = LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_counter.wizard.description
tt_content_defValues {
CType = counter
}
}
}
show := addToList(*)
}'
);
ext_tables.php:
defined('TYPO3_MODE') || die('Access denied.');
call_user_func(
function()
{
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile('my_test', 'Configuration/TypoScript', 'Test');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_mytest_domain_model_basic', 'EXT:my_test/Resources/Private/Language/locallang_csh_tx_mytest_domain_model_basic.xlf');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_mytest_domain_model_basic');
}
setup.typoscript:
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:fluid_styled_content/Configuration/TypoScript/setup.txt">
page = PAGE
page {
typeNum = 0
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
key.data = pagelayout
pagets__site_package_default = TEXT
pagets__site_package_default.value = Default
default = TEXT
default.value = Default
}
templateRootPaths {
0 = EXT:my_test/Resources/Private/Templates/Page/
1 = {$page.fluidtemplate.templateRootPath}
}
partialRootPaths {
0 = EXT:my_test/Resources/Private/Partials/
1 = {$page.fluidtemplate.partialRootPath}
}
layoutRootPaths {
0 = EXT:my_test/Resources/Private/Layouts/
1 = {$page.fluidtemplate.layoutRootPath}
}
}
}
lib.contentElement {
templateRootPaths {
20 = EXT:my_test/Resources/Private/Templates/Content/
}
}
tt_content.counter =< lib.contentElement
tt_content.counter {
templateName = Counter
}
tt_content.slider =< lib.contentElement
tt_content.slider {
templateName = Slider
}
);
TCA/Overrides/tt_content.php:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_slider',
'slider',
'EXT:my_test/Resources/Public/icons/blue.png'
),
'CType',
'Myext'
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
array(
'LLL:EXT:my_test/Resources/Private/Language/Tca.xlf:myext_counter',
'counter',
'EXT:my_test/Resources/Public/icons/blue.png'
),
'CType',
'Myext'
);
Templates/Content/Counter.html:
<html xmlns:flux="http://typo3.org/ns/FluidTYPO3/Flux/ViewHelpers" flux:schemaLocation="http://fluidtypo3.org/schemas/flux-development.xsd"
xmlns:fcc="http://typo3.org/ns/FluidTYPO3/FluidcontentCore/ViewHelpers" fcc:schemaLocation="http://fluidtypo3.org/schemas/fluidcontent_core-development.xsd"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers" v:schemaLocation="http://fluidtypo3.org/schemas/vhs-development.xsd"
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers" f:schemaLocation="http://fluidtypo3.org/schemas/fluid-master.xsd">
<f:layout name="Default"/>
<f:section name="Configuration">
<flux:form id="counter"
label="counter"
description="Counter description">
<flux:form.option.icon value="EXT:my_test/Resources/Public/icons/blue.png"/>
<flux:form.option.group value="Test" />
<flux:form.section name="counters" label="Counter">
<flux:form.object name="item" label="Counter item">
<flux:field.input name="title" label="Counter title" placeholder="Counter title" required="true" />
</flux:form.object>
</flux:form.section>
</flux:form>
</f:section>
<f:section name="Preview"></f:section>
<f:section name="Main">
<h1>Counter check!</h1>
</f:section>
</html>
该元素可以在向导中看到并在前端呈现,但是当我想在后端编辑它时,它没有后端字段,除了带有元素类型的下拉列表。我想我没有添加一些配置来让它工作,但我不知道它可能是什么。
我解决了这个问题。 ext_localconf.php 中缺少以下行:
\FluidTYPO3\Flux\Core::registerProviderExtensionKey('MyTest.my_test', 'Content');
那么我不需要tt_content.php中的代码,因为它添加到下拉列表的项目与后端布局无关。新的内容元素会自动从模板文件添加到下拉列表中,并使用以下信息:
<flux:form id="counter"
label="counter"
description="Counter description">