TYPO3 8.7自定义内容元素的后端字段未呈现

时间:2019-09-25 08:40:13

标签: typo3 fluid typo3-8.x

我在TYPO3 8.7上有一个模板扩展,并尝试添加一些自定义内容元素。除了后端字段,其他所有内容似乎都可以正常工作-它们只是未呈现。

我从头开发了扩展程序,并认为这可能是问题所在,因此我安装了扩展程序构建器模块并对其进行了另一个扩展,但是结果仍然相同。

扩展结构:

    ├── 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>

可以在向导中看到该元素,并在前端中对其进行渲染,但是当我要在后端中对其进行编辑时,除了具有元素类型的下拉列表之外,它没有任何后端字段。我想我并没有添加一些配置来使其工作,但我不知道它可能是什么。

1 个答案:

答案 0 :(得分:1)

我解决了这个问题。 ext_localconf.php中缺少以下行:

\FluidTYPO3\Flux\Core::registerProviderExtensionKey('MyTest.my_test', 'Content');

然后,我不需要tt_content.php中的代码,因为它添加到下拉列表中的项目与后端布局无关。新的内容元素会从模板文件自动添加到下拉列表中,并使用以下信息:

<flux:form id="counter"
           label="counter"
           description="Counter description">