简体   繁体   English

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

[英]How to create typo3 template for content element?

I have created a new content element for slider. 我为滑块创建了一个新的内容元素。 I have added these codes in my typo3 setup 我已经在我的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
        }
    }
}

All these codes enables a section in backend from where I can add slider content. 所有这些代码都在后端中启用了一个部分,可以在其中添加滑块内容。 But while redering it on front end there is an error 但是在前端重做时出现错误

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

I definitely missed something and I have no idea what I have to do. 我肯定错过了一些东西,我也不知道该做什么。 I am new in Typo3. 我是Typo3的新手。

So my question is: 1) How could I define the template for my slider? 所以我的问题是:1)如何为滑块定义模板? Please also suggest the path where I have to write the code. 还请提出我必须编写代码的路径。 2) After it how could I get data from the content element so I can grab it from there and put it in my html design. 2)之后,我如何才能从content元素获取数据,以便可以从那里获取数据并将其放入html设计中。

You need to add a fluid template file to the set of templates files already defined. 您需要将流体模板文件添加到已定义的模板文件集合中。

there probably is a definition like 大概有这样的定义

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

As you never should modify the core itself (don't even add files to these folders) you need to add further folders with your folder path like: 由于您永远不应该修改核心本身(甚至不向这些文件夹添加文件),因此需要使用文件夹路径添加其他文件夹,例如:

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

there you have the template file HomeSlider.html . 那里有模板文件HomeSlider.html in that file you could do a 在该文件中,您可以执行

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

and see what data you could use to work with. 并查看您可以使用哪些数据。 you should find a data object which contains all fields from the tt_content record. 您应该找到一个data对象,其中包含tt_content记录中的所有字段。

Aside from templateRootPaths you also can add values for layoutRootPaths and partialRootpaths to enhance the set of available templates. 除了templateRootPaths您还可以为layoutRootPathspartialRootpaths添加值,以增强可用模板集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM