【问题标题】:How to create typo3 template for content element?如何为内容元素创建typo3模板?
【发布时间】:2019-06-25 17:56:21
【问题描述】:

我为滑块创建了一个新的内容元素。我在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

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 设计中。

【问题讨论】:

    标签: typo3 typo3-9.x


    【解决方案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 添加值以增强可用模板集。

    【讨论】:

      猜你喜欢
      • 2021-01-22
      • 1970-01-01
      • 1970-01-01
      • 2021-12-26
      • 2013-08-30
      • 1970-01-01
      • 2022-08-11
      • 1970-01-01
      • 2020-01-27
      相关资源
      最近更新 更多