简体   繁体   中英

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

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.

So my question is: 1) How could I define the template for my slider? 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.

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 . 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.

Aside from templateRootPaths you also can add values for layoutRootPaths and partialRootpaths to enhance the set of available templates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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