如何为内容元素创建typo3模板?

时间:2019-06-25 17:56:21

标签: typo3 typo3-9.x

我为滑块创建了一个新的内容元素。我已经在我的typo3设置中添加了这些代码

EXT:rapigo\Configuration\TsConfig\Page\Mod\WebLayout\mod.tsconfig

mod.wizards.newContentElement.wizardItems.common {
    elements {
        rapigo_home_slider {
            iconIdentifier = content-carousel-image
            title = Home Slider
            description = A content element to add one or more images
            tt_content_defValues.CType = rapigo_home_slider
        }
    }
    show := addToList(rapigo_home_slider)
}

EXT:rapigo\Configuration\TCA\Overrides\tt_content_my_extension_my_slider.php

https://www.eclipse.org/lists/m2e-dev/msg00904.html

Ext:rapigo\Configuration\TypoScript\myslider.typoscript

tt_content {
    my_extension_my_slider < lib.contentElement
    my_extension_my_slider {
        templateName = HomeSlider
        dataProcessing {
            10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
            10.references.fieldName = assets
        }
    }
}

所有这些代码都启用了后端中的一个部分,可以在其中添加滑块内容。但是在前端重做时会出现错误

ERROR: Content Element with uid "26" and type "rapigo_home_slider" has no rendering definition!

我肯定错过了一些事情,我也不知道该做什么。我是Typo3的新手。

所以我的问题是: 1)如何为滑块定义模板?还请提出我必须编写代码的路径。 2)之后,如何从内容元素中获取数据,以便从那里获取数据并将其放入html设计中。

1 个答案:

答案 0 :(得分:1)

您需要将流体模板文件添加到已经定义的模板文件集中。

大概有一个类似

的定义
lib.contentElement.templateRootPaths.0 = EXT:fluid_styled_content/Resources/Private/Templates/

由于您永远不应该修改核心本身(甚至不向这些文件夹添加文件),因此需要使用文件夹路径添加其他文件夹,例如:

lib.contentElement.templateRootPaths.5 = EXT:rapigo/Resources/Private/Templates/

您有模板文件HomeSlider.html。在该文件中,您可以执行

<f:debug title="all data available in HomeSlider.html">{_all}</f:debug>

,然后查看可以使用哪些数据。您应该找到一个data对象,其中包含tt_content记录中的所有字段。

除了templateRootPaths以外,您还可以为layoutRootPathspartialRootpaths添加值以增强可用模板集。

相关问题