multiple aspects why you should not work in this way:
prefer .templateName
instead of .template.file
it is more flexible as you can have multiple outputs (.html
, .xml
, .json
, ...)
the layout
field is by default not inherited.
you need to define the field value for each page
TS-conditions result in multiple cached versions of the typoscript
the backend does not represent the frontend layout for your editors
Alternative:
use the fields backend_layout
and backend_layout_next_level
like this:
templateName = TEXT
templateName.cObject = CASE
templateName.cObject {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
#Default Template
default = TEXT
default.value = Default
pagets__startpage = TEXT
pagets__startpage.value = Startpage
pagets__simple = TEXT
pagets__simple.value = Simple
}
or you use the value direct:
templateName = TEXT
templateName {
value = default
override.cObject = TEXT
override.cObject {
data = levelfield:-1, backend_layout_next_level, slide
override.field = backend_layout
}
}
The backend layouts are defines in page TSconfig (deployable from EXT:my_site_ext/Configuration/TSconfig/page.tsconfig
)
## define backend-layouts
mod.web_layout.BackendLayouts {
startpage {
title = Startpage Layout
config {
backend_layout {
colCount = 4
rowCount = 4
rows {
:
}
}
}
}
simple {
title = Simple Layout
config {
backend_layout {
colCount = 2
rowCount = 2
rows {
:
}
}
}
}
default {
title = Default Layout
config {
backend_layout {
colCount = 4
rowCount = 3
rows {
:
}
}
}
}
}
if you want the layout
field to adapt the general frontend template you need to transfer this information into the fluid-template:
variables {
:
layout = TEXT
layout.field = layout
:
}
Then you can consider the layout in your template (or layout) files:
<f:if condition="{layout} == 1">
<then><f:render partial="header1" /></then>
<else><f:if condition="{layout} == 2">
<then><f:render partial="header2" /></then>
<else><f:render partial="header0" /></else></fi>
</else>
</fi>
and also here you can use the value immediatly (be sure to have all partials available):
<f:render partial="header{layout}" />
In general you can use these two fields in multiple ways, here some other usages:
typoscript:
page.10.template {
templateName = Default
variables {
beLayout = TEXT
beLayout.data = levelfield:-1, backend_layout_next_level, slide
beLayout.override.field = backend_layout
feLayout = TEXT
feLayout.field = layout
:
}
}
1.
you use a static template, and the BE- and FE-layout fields are fluid variables which decide further rendering in fluid:
in Templates/Default.html:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:layout name="{beLayout}" />
<f:section name="Main">
<f:if condition="{feLayout} == 1">
<div class="col-visual">{content_visual->f:format.raw()}</div>
</f:if>
<div class="col-main">{content_main->f:format.raw()}</div>
<f:if condition="{feLayout} == 2">
<div class="col-infobox">{content_infobox->f:format.raw()}</div>
</f:if>
</f:section>
2.
in Templates/Default.html:
<f:render partial="{beLayout}" section="{feLayout}" arguments="{_all}" />
3.
in Templates/Default.html: