Reputation: 180
I'm trying to create my own content element in TYPO3 v12, but the template of it is not being rendered. Based on the template code, the HTML code that should be displayed would look like this:
<header class="header">
<div class="af6bus__banner">Test</div>
</header>
However, what I'm getting is:
<header class="header"></header>
I've checked if the typoscript is included in the root page, which was the case. I've also tried removing the rendering registration which resultet, as expected, in the error "content element has no rendering definition".
Here is my current code:
af6bus/Resources/Private/Layouts/Default.html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<span class="anchor" id="top"></span>
<f:render section="content" />
</html>
af6bus/Resources/Private/Templates/Default.html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="content">
<header class="header">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '100'}" />
</header>
<main class="main">
<f:cObject typoscriptObjectPath="lib.dynamicContent" data="{colPos: '0'}" />
</main>
<a href="#top" class="scroll--top"></span></a>
<footer class="footer">
</footer>
</f:section>
</html>
af6bus/Resources/Private/Templates/Banner.html
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:layout name="Default" />
<f:section name="content">
<div class="af6bus__banner">Text</div>
</f:section>
</html>
af6bus/Configuration/TypoScript/Setup/template.typoscript
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap {
cObject = CASE
cObject {
key.data = pagelayout
default = TEXT
default.value = Default
pagets__default = TEXT
pagets__default.value = Default
pagets__nobanner = TEXT
pagets__nobanner.value = NoBanner
}
}
layoutRootPaths {
10 = EXT:af6bus/Resources/Private/Layouts/
}
templateRootPaths {
10 = EXT:af6bus/Resources/Private/Templates/
}
partialRootPaths {
10 = EXT:af6bus/Resources/Private/Partials/
}
variables {
siteName = TEXT
siteName.value = {siteLanguage:websiteTitle}
siteName.insertData = 1
homePid = TEXT
homePid.value = {$homePid}
footerPid = TEXT
footerPid.value = {$footerPid}
}
}
}
lib.dynamicContent = COA
lib.dynamicContent {
10 = LOAD_REGISTER
10.colPos.cObject = TEXT
10.colPos.cObject {
field = colPos
ifEmpty.cObject = TEXT
ifEmpty.cObject {
value.current = 1
ifEmpty = 0
}
}
20 = CONTENT
20 {
table = tt_content
select {
orderBy = sorting
where = {#colPos}={register:colPos}
where.insertData = 1
}
}
90 = RESTORE_REGISTER
}
## Banner-Template
tt_content {
af6bus_banner =< lib.dynamicContent
af6bus_banner {
templateName = Banner.html
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = assets
}
}
}
}
Upvotes: 0
Views: 538
Reputation: 180
So after some trial and error I have finally made it work. Now I'm not sure wether or not this is the ideal solution, but it works.
In my TypoScript file af6bus/Configuration/TypoScript/Setup/template.typoscript I adjusted the rendering and replaced lib.dynamicContent with lib.contentElement. I also removed the .html from the template name. This is how the code looks now.
tt_content {
af6bus_banner =< lib.contentElement
af6bus_banner {
templateName = Banner
templateRootPaths.100 = EXT:af6bus/Resources/Private/Templates/
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = assets
}
}
}
}
As for the template, I simply changed the section name from content to Main.
Upvotes: 0