Different Frontend-Layouts in TYPO3 - typo3

I'm trying to use different Frontend-Layouts in TYPO3. So I'm using this fancy TypoScript:
page {
bodyTag = <body>
10= CASE
10.key.field=layout
# Standardtemplate
10.0 = TEMPLATE
10.0.template = FILE
10.0.template.file = fileadmin/template/content_template.html
10.0.workOnSubpart = DOCUMENT_BODY
# Variante 1:
10.1 = TEMPLATE
10.1.template = FILE
10.1.template.file = fileadmin/template/index_template.html
10.1.workOnSubpart = DOCUMENT_BODY
includeJSFooter {
jquery = fileadmin/template/js/jquery.js
bootstrap = fileadmin/template/js/bootstrap.min.js
app = fileadmin/template/js/app.js
}
includeCSS {
robotoFont = https://fonts.googleapis.com/css?family=Roboto:100,400
robotoFont.external = 1
robotoFont.media = all
bootstrapCore = fileadmin/template/css/bootstrap.min.css
bootstrapCore.media = all
}
}
This is not working yet. Every single page is completely. Only a white page appears. I'm using TYPO3 7.6.16. Is there any issue in my code above?

It think you are looking for this just place it in the PAGE-Element and rename the Path and also create some BackendLayouts named as value in layout 1. 2. 3. e.g. hope this will help:
10 = FLUIDTEMPLATE
10 {
file = fileadmin/templates/Page/Standard.html
partialRootPath = fileadmin/templates/Partials/
variables {
layout = CASE
layout {
key.field = backend_layout
key.ifEmpty.data = levelfield:-2, backend_layout_next_level, slide
1 = TEXT
1.value = startpage
2 = TEXT
2.value = subpage
3 = TEXT
3.value = subpagespecial
default = TEXT
default.value = subpage
}
content = CONTENT
content {
table = tt_content
select.orderBy = sorting
select.where = colPos=0
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
header = CONTENT
header {
table = tt_content
select.orderBy = sorting
select.where = colPos=1
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
content2 = CONTENT
content2 {
table = tt_content
select.orderBy = sorting
select.where = colPos=3
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
contentfull = CONTENT
contentfull {
table = tt_content
select.orderBy = sorting
select.where = colPos=2
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
}
}

Please add a default variant in the CASE object. It may be that pages which are created anew do not have a '0' in its 'layout' column.
Did you verify that the subpart markers are spelled correctly?
<!-- ###DOCUMENT_BODY### begin -->
Your HTML template
<!-- ###DOCUMENT_BODY### end -->
You could simplify your TypoScript template:
page {
10 = TEMPLATE
10.template = FILE
10.template.file = CASE
10.template.file {
key.field = layout
default = TEXT
default.value = fileadmin/template/content_template.html
1 = TEXT
value = fileadmin/template/index_template.html
}
10.workOnSubpart = DOCUMENT_BODY
}

Related

TYPO3 - simpler way, rendering content from colPos into Fluidtemplate?

The official TYPO3 Documentation explains how to create (or copy) and use a lib.dynamicContent to render columns into a Fluidtemplate.
I do not understand exactly whats going on in this example.
The TypoScript there is:
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
}
I use this snippet in a ton of TYPO3 projects and often had asked myself whats going on there.
I have changed this by experimenting a bit and ended with:
lib {
dynamicContent = COA
dynamicContent {
10 = CONTENT
10 {
table = tt_content
select {
orderBy = sorting
where {
data = field:colPos
wrap = colPos=|
}
}
}
}
}
That seems to do "exactly the same" thing - it outputs my content when called via cObject ViewHelper.
Can somebody explain if or why this is the worse way to render Content?
Here's the link to the lib.dynamicContent-doc: https://docs.typo3.org/c/typo3/cms-fluid-styled-content/master/en-us/Installation/InsertingContentPageTemplate/Index.html#based-on-the-fluidtemplate-content-object-cobj
Here you go!
you can try this,
# Clear out any constants in this reserved room!
styles.content >
# get content
styles.content.get = CONTENT
styles.content.get {
table = tt_content
select.orderBy = sorting
select.where = colPos=0
}
# Left Column
styles.content.getLeft < styles.content.get
styles.content.getLeft.select.where = colPos=1
# Right content
styles.content.getRight < styles.content.get
styles.content.getRight.select.where = colPos=2
Also, you can use variable in the fluid page object, check this out:
lib.pageTemplate = FLUIDTEMPLATE
lib.pageTemplate {
variables {
content = CONTENT
content {
table = tt_content
select.orderBy = sorting
select.where = colPos=0
}
contentRight = CONTENT
contentRight {
table = tt_content
slide = -1
select.orderBy = sorting
select.where = colPos=2
}
}
}
You can find out more here:
Adding the page content to a fluid template
Typo3 7.6 typoscript problems with markers
Hope this make sense, Cheer...!
You should look at this snippet together with some information about the Fluid view helper <f:cObject> which can be found here: https://docs.typo3.org/other/typo3/view-helper-reference/9.5/en-us/typo3/fluid/latest/CObject.html
As you can see there are the parameters data, currentValueKey and table that will be handed over to the typoscriptObjectPath, which is why the snippet makes perfect sense. The reason is, that it's a bit hard to put the different options into the where clause of the CONTENT object. So it increases readability and those registers can be easily extended.
So the register in this example is used to put in either the value of the data field colPos or if that is empty it will take the current value from the currentValueKey and if that is empty too it will fall back to a value of 0 to make sure the query won't produce an exception.
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
}
We used a modified version of that snippet to sneak in some more parameter values for the CONTENT object.
So we can hand over a data field pageUid, if that is not set we will use the uid of the current page. This will be overriden if the current or the target page is configured to show content from another page and finally we can trigger a slide with another data field.
lib.dynamicContent = COA
lib.dynamicContent {
5 = LOAD_REGISTER
5 {
colPos.cObject = TEXT
colPos.cObject {
field = colPos
ifEmpty.cObject = TEXT
ifEmpty.cObject {
value.current = 1
ifEmpty = 0
}
}
pageUid.cObject = TEXT
pageUid.cObject {
field = pageUid
ifEmpty.data = TSFE:id
}
contentFromPid.cObject = TEXT
contentFromPid.cObject {
data = DB:pages:{register:pageUid}:content_from_pid
data.insertData = 1
}
}
20 = CONTENT
20 {
table = tt_content
slide = -1
slide.if.isTrue.field = slide
select {
includeRecordsWithoutDefaultTranslation = 1
orderBy = sorting
where = {#colPos}={register:colPos}
where.insertData = 1
pidInList.data = register:pageUid
pidInList.override.data = register:contentFromPid
}
}
90 = RESTORE_REGISTER
}
This enables us to make use of the <f:cObject> view helper while triggering additional parameters just by handing over some more values within the data array.

How to get my other TYPO3 FE templates?

Although it seems so simple I only get one template in my FE. While the BE-layouts are working fine, I do not get any of my other FE-templates. Only the DefaultTemplate is popping up every time. After trying all kind of samples/ topics read, etc, I’m stuck on this. Here is my set-up.
The TSconfig and PageTS all other files are stored in the extension.
# Layout Select box for the FE templates
TCEFORM.pages {
layout.altLabels.3 = NewsLetterTemplate
layout.altLabels.2 = RedFooterTemplate
layout.altLabels.1 = DefaultTemplate
layout.altLabels.0 = DefaultTemplate
removeItems = 4,5,6,7,9,10
}
###########################################
# Config Fluid Template
page = PAGE
page.typeNum = 0
page.10 = FLUIDTEMPLATE
page.10{
#Path to the template files stored extension
partialRootPath = {$resDir}/Private/Partials
layoutRootPath = {$resDir}/Private/Layouts
file = {$resDir}/Private/Templates/DefaultTemplate.html
templateName = TEXT
templateName.stdWrap.cObject = CASE
templateName.stdWrap.cObject {
key.data = pagelayout
default = TEXT
default.value = {$resDir}/Private/Templates/DefaultTemplate.html
#Default template
pagets__DefaultTemplate = TEXT
pagets__DefaultTemplate.value = {$resDir}/Private/Templates/DefaultTemplate.html
#Second template
pagets__RedFooterTemplate = TEXT
pagets__RedFooterTemplate.value = {$resDir}/Private/Templates/RedFooterTemplate.html
#Third template
pagets__NewsLetterTemplate = TEXT
pagets__NewsLetterTemplate.value = {$resDir}/Private/Templates/NewsLetterTemplate.html
}
#Here some variables for use in the template by using {}
variables {
siteName = TEXT
siteName.value = PIZZAWORKSHOP.nl
pageTitle = TEXT
pageTitle.data = page:title
#get the content into the template:
content < styles.content.get
#Maincontent
content_main < styles.content.get
content_main.select.where = colPos = 0
#Content Colom 1
content_column_1 < styles.content.get
content_column_1.select.where = colPos = 1
#Content Colom 2
content_column_2 < styles.content.get
content_column_2.select.where = colPos = 2
}
}
https://pastebin.com/9TLytchv
Maybe one of you can point me into the right direction here? Thanks.
W.
You can add this typoscript Page TSConfig on resource tabe in page properties. For this typoscript you can rename defult frontend layout name.
TCEFORM.pages {
layout.altLabels.3 = NewsLetterTemplate
layout.altLabels.2 = RedFooterTemplate
layout.altLabels.1 = DefaultTemplate
layout.altLabels.0 = DefaultTemplate
}
For use different frontend layout like this.
[globalVar=TSFE:page|layout=3]
page.10.template.file = fileadmin/template/shinynewtemplate.html
page.includeCSS.screen = fileadmin/template/css/style.css
page.includeCSS.screen.media = screen
[global]

Use a variable in Typoscript "select"

I try to get an author of a Typo3 site and after this i try to fill a Typo3 select (typoscript) with the resulting ID.
Its somehow working, but i can not use the lib oder variable as datasource of another select
I tryed to play arround with LOAD_REGISTER or marker. But i think it has to be a way to use a select result or another "lib" result in a select.
Here is my code:
// Returns succsessfully "neuz8" and i can use this in fluid
lib.author = TEXT
lib.author.data = page:author
lib.Authornavigation = CONTENT
lib.Authornavigation {
stdWrap.required = 1
table = be_users
select {
uidInList = 0
pidInList = root
selectFields = be_users.uid as id, be_users.realName as rn, be_users.profile_pid as prid
where = be_users.profile_pid != '0'
andWhere = be_users.realName={lib.author} // Is not working, why?
// I tryed: combinations of andWhere.data or lib.author.data,
// with and without {},
// with LOAD_REGISTER,
// with "markers",
//andWhere = be_users.realName='neuz8' < this works and returns "39", the correct ID
andWhere.wrap =
markers {
//author.data = {page:author}
}
}
renderObj = COA
renderObj {
10 = TEXT
10.field = prid
10.wrap2 = ###SPLITTER### |
}
stdWrap.split {
token = ###SPLITTER###
cObjNum = 1 |*| 2 |*| 1
1.current = 1
2.current = 1
2.wrap = |,
}
}
This should work
replace
// andWhere = be_users.realName={lib.author} // Is not working, why?
with
andWhere = be_users.realName=
andWhere.postCObject < temp.author
You can try select.markers:
page.60 = CONTENT
page.60 {
table = tt_content
select {
pidInList = 73
where = header != ###whatever###
orderBy = ###sortfield###
markers {
whatever.data = GP:first
sortfield.value = sor
sortfield.wrap = |ting
}
}
}
Docs » Functions » select (see part markers)

Refer to media field of original language in TYPO3

In TYPO3 6.2 (just upgraded from 4.5) I have a TMENU with Images, using a cObject in NO to build the menu as desired.
It works in the main language, but in the second language's frontend, the images are not rendered - unless they are filled in in the second language's media field.
How do you force FILES to refer to the media field of the original language?
In my case, always. In other cases, a fallback solution may be desired.
temp.menu = COA
temp.menu {
wrap = <div class="teasermenu">|</div>
15 = HMENU
15 {
special = list
//special.value.cObject < temp.displayedpages
// recieves a list, such as:
special.value = 1,3,9
1 = TMENU
1 {
noBlur = 1
maxItems = 16
wrap = <ul>|</ul>
NO {
wrapItemAndSub = <li>|</li>
ATagBeforeWrap = 1
ATagParams = || || || || class="red" |*| |*|
stdWrap.cObject=COA
stdWrap.cObject{
10 = TEXT
10.field = nav_title // title
10.wrap = <strong class="teasermenu_header">|</span></strong>
20=FILES
20{
if{
isInList.field = uid
//value.cObject < temp.displayedpages_wimage
// receives another list, like:
// value = 3,9
}
references {
table=pages
fieldName=media
}
renderObj=IMAGE
renderObj{
file{
height=80
maxH=80
import.data=file:current:publicUrl
}
altText.field=title
titleText.field=title
}
}
}
}
}
}
}
PS there are many media field / FAL fallback related bugs on forge, e.g. this one. But I have a feeling this might be a simpler issue.
mergeIfNotBlank is gone now, the current solution (TYPO3 8.7) seems to be to set
$GLOBALS['TCA']['pages']['columns']['media']['config']['behaviour']['allowLanguageSynchronization'] = 1;
But based on https://forum.typo3.org/index.php/t/217033/-typo3-ug-freiburg-media-feld-in-den-seiteneigenschaften (thanks) there's this snippet. It also works with cropVariants:
temp.bgimg_wide = CONTENT
temp.bgimg_wide{
table = sys_file_reference
select{
pidInList = {$pids.pidHome}
where = tablenames='pages' AND fieldname='media'
orderBy = sorting_foreign
languageField = 0
selectFields = uid_local
max = 1
begin = 0
}
renderObj = FILES
renderObj{
files.stdWrap.field = uid
renderObj = IMG_RESOURCE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 1600
cropVariant = bgimg_wide
}
}
}
}
}
This works!
With TYPO3 CMS 7.6 you need to exclude field media of table pages from [FE][pageOverlayFields] as set in ~/typo3_src-7.6.10/typo3/sysext/core/Configuration/DefaultConfiguration.php, until it is solved - see forge issue https://forge.typo3.org/issues/65863
Write in your AdditionalConfiguration
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = 'uid,doktype,title,subtitle,nav_title,keywords,description,abstract,author,author_email,url,urltype,shortcut,shortcut_mode';
or in your Extension ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = str_replace(',media', '', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
Based on Urs' answer, here comes a slight variation.
lib.getCurrentPageMedia = CONTENT
lib.getCurrentPageMedia {
table = sys_file_reference
select{
pinInList = root, this
where = tablenames='pages' AND fieldname='media' AND uid_foreign=###pid###
orderBy = sorting_foreign
languageField = 0
selectFields = uid_local
max = 1
begin = 0
markers {
pid.data = TSFE:id
}
}
renderObj = TEXT
renderObj.stdWrap.field = uid
}
Fluid:
<f:image src="{f:cObject(typoscriptObjectPath:'lib.getCurrentPageMedia')}" alt="" width="400c" height="400c" treatIdAsReference="1" class="img-responsive" />
Advantage: you can define cropping, alt-text, etc. in your template.
You might want to try to set the TCA of the media field to l10n_mode => mergeIfNotBlank .
http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#columns-properties-l10n-mode
Put this into the typo3conf/AdditionalConfiguration.php:
$TCA['pages']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';
Since this issue is from Februari, you've probably found a solution by now. I just ran into this issue and solved it by including:
$GLOBALS['TCA']['pages_language_overlay']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';
in my ext_tables.php

The detailed view of the last item of a list build by TypoScript is always blank

Here's the TypoScript code.
lib.membersList = CONTENT
lib.membersList{
table = tt_address
select{
pidInList = {$membersStorageFolder}
orderBy = zip, last_name
}
wrap = <div class="membersList">|</div>
renderObj = COA
renderObj{
10 = FLUIDTEMPLATE
10{
file = fileadmin/templates/ext/memberslist/templates/membersList.html
variables{
portrait = IMAGE
portrait{
file.import = uploads/pics/
file.import {
field = image
listNum = 0
}
file.height = 105
file.width = 105c
stdWrap.typolink{
parameter = {$membersPageId}
additionalParams.dataWrap = &ts_addresslist[showUid]={field:uid}
#returnLast = url
# The cache hash is needed to display the right content, since we are not running as USER_INT
useCacheHash = 1
}
}
lastName = TEXT
lastName.field = last_name
lastName.typolink{
parameter.data = TSFE:id
additionalParams.dataWrap = &ts_addresslist[showUid]={field:uid}
# The cache hash is needed to display the right content, since we are not running as USER_INT
useCacheHash = 1
}
firstName = TEXT
firstName.field = first_name
firstName.typolink{
parameter.data = TSFE:id
additionalParams.dataWrap = &ts_addresslist[showUid]={field:uid}
# The cache hash is needed to display the right content, since we are not running as USER_INT
useCacheHash = 1
}
title = TEXT
title.field = title
organisation = TEXT
organisation.field = company
country = TEXT
country.field = country
city = TEXT
city.field = city
}
}
}
stdWrap.override.cObject = CONTENT
stdWrap.override.cObject{
table = tt_address
select {
andWhere.data = GP:ts_addresslist|showUid
# Make sure there is no SQL injection!
andWhere.intval = 1
andWhere.wrap = uid=|
orderBy = last_name ASC
pidInList = {$membersStorageFolder}
}
wrap = <div class="membersDetail">|</div>
renderObj = FLUIDTEMPLATE
renderObj{
file = fileadmin/templates/ext/memberslist/templates/membersDetail.html
variables{
portrait = IMAGE
portrait{
file.import = uploads/pics/
file.import {
field = image
listNum = 0
}
file.height = 105
file.width = 105c
}
lastName = TEXT
lastName.field = last_name
firstName = TEXT
firstName.field = first_name
title = TEXT
title.field = title
organisation = TEXT
organisation.field = company
country = TEXT
country.field = country
city = TEXT
city.field = city
detail = TEXT
detail.field = description
}
}
renderObj.stdWrap.append = TEXT
renderObj.stdWrap.append{
value = << Back to list
typolink.parameter = {$membersPageId}
}
}
stdWrap.override.if {
isTrue.data = GP:ts_addresslist|showUid
isTrue.intval = 1
}
}
Everything is working fine. The list is displayed as it should. The detailed view also except for the last item. When I click on it, the detailed view displays a blank page. No information, as if the query fetched nothing.
Here are the templates, very simple though.
membersList.html
<section>
{portrait -> f:format.raw()}
<div class="memberDetail">
<h1>{lastName -> f:format.raw()} {firstName -> f:format.raw()}</h1>
<h2>{title} - {organisation}</h2>
<h3>{country} - {city}</h3>
</div>
</section>
membersDetail.html
<section>
{portrait -> f:format.raw()}
<div class="memberDetail">
<h1>{lastName} {firstName}</h1>
<h2>{title} - {organisation}</h2>
<h3>{country} - {city}</h3>
</div>
<div class="bio">
{detail}
</div>
</section>
Your code looks right so far. For debugging purpose add it directly to page object.
page.38388383 = CONTENT
page.38388383 {
table = tt_address
select{
pidInList = {$membersStorageFolder}
orderBy = zip, last_name
}
wrap = <div class="membersList">(|)</div>
renderObj = COA
renderObj{
10 = TEXT
10.field = uid
10.wrap = (|),
}
}
With this, you should get a comma separated list of all tt_address records without sideeffects. If that does not work, check on database level if everything is correct. Perhaps you some trouble with language, workspace or so...?
If this works like expected, you can replace your renderObj with this one and see what happens.
If expect that there is no crazy loop effect - but some CMS sideeffects (like missing rights, language, workspace version etc.).