Reputation: 55
I have these template structure
Resources/private/Layouts/default.html
Resources/private/Partials/Footer.html
Resources/private/Partials/Header.html
Resources/private/Partials/Search.html
Resources/private/Templates/Default.html
I want to render 1column structure, 2column structure, Default(Home) Page structure.
This is my setup.typoscript
page {
typeNum = 0
shortcutIcon = EXT:demo_site/Resources/Public/Icons/favicon.ico
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
key.data = pagelayout
pagets__default = TEXT
pagets__default.value = Default
pagets__2column = TEXT
pagets__2column.value = 2column
pagets__1column = TEXT
pagets__1column.value = 1column
default = TEXT
default.value = Default
default <.pagets__2column
Resources/private/Templates/Default.html
<f:section name="Jumbotron">
--------
</f:section>
<f:section name="2column">
--------
</f:section>
<f:section name="1column">
--------
</f:section>
Resources/private/Layouts/default.html
<f:if condition ="{templateName} == 'Jumbotron'">
<f:render section="Jumbotron"/>
</f:if>
<f:if condition ="{templateName} == '2column'">
<f:render section="2column"/>
</f:if>
<f:if condition ="{templateName} == '1column'">
<f:render section="1column"/>
</f:if>
My header footer is included successfully. But I am getting problem to render different templates. So Please tell, Do I use right if condition? if not then please tell the solution What should I do to render the different templates?
Upvotes: 0
Views: 544
Reputation: 10791
Aside from some misconceptions or typos:
You have selected the different templates but you have not provided the template name as variable to your template.
You need something like this in your FLUIDTEMPLATE
object after the templateName definition:
page.10 {
templateName = ...
templateName.stdWrap.cObject {
:
}
// copy template name to a variable:
variables.templateName < .templateName
// define further variables:
variables {
:
}
}
It looks like you do not really use different templates but that you may want to use different partials (or sections) for different layouts.
Then you do not need different template files and the definition of page.10.templateName is not necessary. Be sure to have the construct for the fluid-variable.
you have two default
assignements in your CASE
object. the first will be overwritten from second. (with the same values)
you use the field pagelayout
with the values usually used for the fields backend_layout
and backend_layout_next_level
.
maybe this is a clean solution for you:
page {
10 = FLUIDTEMPLATE
10 {
templateName = Default
variables {
templateName = CASE
templateName {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
default = TEXT
default.value = Default
pagets__default = TEXT
pagets__default.value = Default
pagets__2column = TEXT
pagets__2column.value = 2column
pagets__1column = TEXT
pagets__1column.value = 1column
:
}
:
}
}
}
and your template file (Default.html
) should hold this call:
<f:render section="{templateName}" arguments="{_all}" />
though I would prefer to use partials instead of sections, and rename the variable to something like layout
as it selects no template
Upvotes: 2