Conditions with Typoscript for Fluidtemplates - typo3

I want to add a fluidtemplate with the following code
[PIDupinRootline = 39] && [treeLevel = 4]
lib.personSubMenuBack = FLUIDTEMPLATE
lib.personSubMenuBack {
file = EXT:sitepackage_my_domain/Resources/Private/TT_Address/Partials/PersonSubMenuBack.html
}
[end]
In another fluidtemplate I added
<f:cObject typoscriptObjectPath="lib.personSubMenuBack" />
Now I get errors for the pages when the condition is wrong because 'lib.personSubMenuBack' isn't found . To avoid this I added this before the condition
lib.personSubMenuBack = FLUIDTEMPLATE
lib.personSubMenuBack {
file = EXT:sitepackage_my_domain/Resources/Private/TT_Address/Partials/PersonSubMenuEmpty.html
}
I wonder if there is a more elegant way to solve the problem without an additional empty fluidtemplate PersonSubMenuEmpty

[PIDupinRootline = 39] && [treeLevel = 4]
lib.personSubMenuBack = FLUIDTEMPLATE
lib.personSubMenuBack {
file = EXT:sitepackage_my_domain/....
}
[else]
lib.personSubMenuBack = TEXT
[end]

Related

TYPO3 MenuProcessor with dynamic uid

I want to use the MenuProcessor dynamic in my fluidtemplate.
Configured in TypoScript, I want to call it with the cObject ViewHelper and pass the uid of a page to it:
{f:cObject(typoscriptObjectPath: 'lib.menuTest', data:{menuId:'28'})}
This is what I have tried - it should be a special = directory with the the given uid in special.value = XXXXXX.
lib {
menuTest = FLUIDTEMPLATE
menuTest {
templateName = MenuTest
templateRootPaths {
10 = EXT:hatemplate/Resources/Private/Templates/
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value = XXXXXX
levels = 1
as = menuItems
}
}
}
}
If I set a uid directly it works, but I don't know how to insert the variable. Has anyone a hint or a working solution?
Thank you
I have solved it with the help of a friend who is much more experienced in TypoScript.
I wasn't as wrong as I thought.
This is the Code in TypoScript. I added the tamplate,layout and partial paths for future copy/pasting :) :
lib {
menuDirectory = FLUIDTEMPLATE
menuDirectory {
templateName = MenuDirectory
layoutRootPaths {
10 = EXT:hatemplate/Resources/Private/Layouts/
}
templateRootPaths {
10 = EXT:hatemplate/Resources/Private/Templates/
}
partialRootPaths {
10 = EXT:hatemplate/Resources/Private/Partials/
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
special = directory
special.value.field = menuId
levels = 1
as = directory
}
}
}
}
With this configured you can use the f:cObject ViewHelper like this:
<f:cObject typoscriptObjectPath="lib.menuDirectory" data="{menuId:1}" />
Or inline
{f:cObject(typoscriptObjectPath: 'lib.menuDirectory', data:{menuId:1})}
This renders the Items into the fluidtemplate:

Pass Fluid variable to TypoScript

I want to pass a variable (uid of category) in Fluid to a TypoScript :
<f:cObject typoscriptObjectPath="lib.testFluid" data="{setting.myvar}/>
Then i want to use the var to get all content elements in folder with pid 942 and the category {setting.myvar}
lib.testFluid = COA
lib.testFluid = CONTENT
lib.testFluid {
table = tt_content
select {
pidInList = 942
where = selected_categories = |
}
}
This does not work, it creates an MySql syntax error. I also tried using current = 1 instead of the where clause without success. I looked at post TYPO3: pass variable to typoscript via cObject? and I can recreate it but it does not work with my script. (TYPO3 8)
If i use
...
where = selected_categories = 13
....
the scrip will succesfully display all CE with category 13. How do i make it work with a var?
could you try this:
<f:cObject typoscriptObjectPath="lib.testFluid" data="{myvar: setting.myvar}/>
lib.testFluid = CONTENT
lib.testFluid {
table = tt_content
select {
pidInList = 942
where.data = field:myvar
where.intval = 1
where.wrap = selected_categories=|
}
}
hard to test for me but it might work ...
I had to solve it once with markers. I couldn't find another simpler way. I give you a very general solution which you may adapt to your needs. For example you could set the pid value via a typoscript setting which is more elegant than to put it in the snippet code. Please try:
<f:cObject typoscriptObjectPath="lib.testFluid" data="{category: setting.myvar, catPid: 942}" currrentValueKey="category" />
The related TypoScript snippet:
lib.testFluid = COA
lib.testFluid {
10 = LOAD_REGISTER
10 {
category.cObject = TEXT
category.cObject.value.current = 1
catPid.cObject = TEXT
catPid.cObject.value.dataWrap = { field: catPid }
}
20 = CONTENT
20 {
table = tt_content
select {
pidInList.cObject = TEXT
pidInList.cObject.dataWrap = {REGISTER:catPid}
where = selected_categories=###category###
markers {
category.data = REGISTER:category
}
}
}
30 = RESTORE_REGISTER
}

Typoscript: Overwrite Typoscript of an extension

I try to overwrite the typoscript of the extension tx_seobasics. In the tx_seobasics setup.txt I have:
plugin.tx_seobasics {
# Building the page title
10 = TEXT
10.data = page:tx_seo_titletag // page:title
10.trim = 1
10.stdWrap.stdWrap.append = TEXT
10.stdWrap.stdWrap.append.data = TSFE:tmpl|sitetitle
10.stdWrap.stdWrap.append.trim = 1
10.stdWrap.stdWrap.append.required = 1
10.stdWrap.stdWrap.append.if.isTrue = {$plugin.tx_seo.titleWrapAppendSiteTitle}
10.stdWrap.stdWrap.append.noTrimWrap = | - ||
10.stdWrap.noTrimWrap = {$plugin.tx_seo.titleWrap}
10.stdWrap.insertData = 1
10.htmlSpecialChars = 1
10.wrap = <title>|</title>
10.append < .5
20 < .10
20.wrap = <meta name="title" content="|" />
}
Now the idea is that I can set the value for 10.stdWrap.stdWrap.append.data individual for each language.
So my first step/test was I add following typoscript in the setup.txt of my own template:
plugin.tx_seobasics.10.stdWrap.stdWrap.append.data = page:title
This works and instead of the sitetitle that is defined in the template I get the pagetitle as sitetitle.
Now I have 2 problems:
SOLVED First problem: Overwrite .data with .value
Instead of a field I want to add a value directly in typoscript, my idea was:
plugin.tx_seobasics.10.stdWrap.stdWrap.append.value = My own text
or
plugin.tx_seobasics.10.stdWrap.stdWrap.append = TEXT
plugin.tx_seobasics.10.stdWrap.stdWrap.append.value = My own text
both options dont overwrite anything and it still takes the .data = TSFE:tmpl|sitetitle.
So how to overwrite .datawith .value?
Second problem: Set the value for each language separately.
My typoscript setup.txt looks like this:
[globalVar = GP:L = 1]
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_template/Configuration/TypoScript/setup-ch.txt">
[global]
[globalVar = GP:L = 2]
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:my_template/Configuration/TypoScript/setup-en.txt">
[global]
Edit: I had a mistake in my language files: I was closing 2 brackets } } on the same line. Never thought about it, but typoscript seems to not like that.
I currently have no idea for the language-condition problem but for overwriting the .data you should try to empty the data first:
plugin.tx_seobasics.10.stdWrap.stdWrap.append.data >
plugin.tx_seobasics.10.stdWrap.stdWrap.append.value = My own text

TYPO3 fluid variables

I upgrade my TYPO3 from 7.6 to 8.6.
Now I cant set variables via style.content.get, my root template loads fluid_styled_content.
some source:
page.10 = FLUIDTEMPLATE
page.10 {
partialRootPath ={$resDir}/Private/Partials
layoutRootPath = {$resDir}/Private/Layouts
variables {
contentMain < styles.content.get
contentMain.select.where = colPos = 0
contentnew < styles.content.get
contentnew.select.where = colPos = 1
contentkat < styles.content.get
contentkat.select.where = colPos = 2
test = TEXT
test.value = loool
}
}
display the variables:
<f:format.raw> {contentMain} </f:format.raw>
<f:format.raw> {contentnew} </f:format.raw>
<f:format.raw> {contentkat} </f:format.raw>
<f:format.raw> {test} </f:format.raw>
styles.content.get is defined in ext:fluid_styled_content but very late so most copies are empty. References are no solution as the modification for colPos would apply to all references.
At the moment the best solution seems to be an own definition of styles.content.get early in your TS:
styles.content.get = CONTENT
styles.content.get {
table = tt_content
select {
orderBy = sorting
where = colPos=0
}
}
but as it is an own definition I would rename it to temp.content.get so it is identifiable as my own version (no confusion if the global definition changes)
There is a Bug in TYPO3 8.6: https://forge.typo3.org/issues/80044
Add this before you assign styles.content.get to your variables:
<INCLUDE_TYPOSCRIPT: source="FILE:EXT:frontend/ext_typoscript_setup.txt">
Then you can use it just as before.
SOLVED
Thanks to Bernd! Solved this problem.
Here a full example:
mystyles.content.get = CONTENT
mystyles.content.get {
table = tt_content
select {
orderBy = sorting
where = colPos=0
}
}
page.10 = FLUIDTEMPLATE
page.10 {
partialRootPath ={$resDir}/Private/Partials
layoutRootPath = {$resDir}/Private/Layouts
variables {
contentMain < mystyles.content.get
contentMain.select.where = colPos = 0
contentnew < mystyles.content.get
contentnew.select.where = colPos = 1
contentkat < mystyles.content.get
contentkat.select.where = colPos = 2
test = TEXT
test.value = loool
}
}

Fluid Template doesn't load

I'm building a site with Fluid Template. I have created two different front-end layouts and two different back-end layout but I always get this error #1288085266: No template has been specified. Use either setTemplateSource() or setTemplatePathAndFilename(). Accordingly to Typo3 Wiki this should be a solution Exception/CMS/1288085266
but not in my case. This is my code:
config.doctype = html5
page = PAGE
page {
includeCSSLibs.bootstrap = https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css
includeCSS.style = fileadmin/templates/rka2015/css/style.css
includeJSlibs.jquery = https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
includeJSlibs.bootstrap = https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js
includeJS.custom = fileadmin/templates/rka2015/js/custom.js
}
page.10 = FLUIDTEMPLATE
page.10 {
file = fileadmin/templates/rka2015/layouts/main_layout.html
layoutRootPath = fileadmin/templates/rka2015/layouts/
patialRootPath = fileadmin/templates/rka2015/partials/
variables {
siteName = TEXT
siteName.value = rka2015
contentMain < styles.content.get
contentMain.select.where = colPos = 0
content_column_1 < styles.content.get
content_column_1.select.where = colPos = 1
content_column_2 < styles.content.get
content_column_2.select.where = colPos = 2
}
}
page.10.file.stdWrap.cObject = CASE
page.10.file.stdWrap.cObject
{
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
default = TEXT
default.value = fileadmin/templates/rka2015/main_1_column.html
1 = TEXT
1.value = fileadmin/templates/rka2015/main_1_column.html
2 = TEXT
2.value = fileadmin/templates/rka2015/main_2_column.html
}
I have already checked all; section name is OK, ID for back-end layouts are ok, template is defined, everything seem to be as it should be. I really don't have a clue where else to search.
UPDATE!!!
Seems like there is a problem with a file path. I am running my site on a subdomain and it looks like that ts doesn't find the file paths if they are defined only as fileadmin/... Any thoughts? Thanks
SOLUTION!
page {
includeCSSLibs.bootstrap = https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css
includeCSS.style = fileadmin/templates/rka2015/css/style.css
includeJSlibs.jquery = https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
includeJSlibs.jquery.external = 1
includeJSlibs.bootstrap = https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js
includeJS.custom = fileadmin/templates/rka2015/js/custom.js
}
page.10 = FLUIDTEMPLATE
page.10 {
template = CASE
template {
key.data = levelfield:-1,backend_layout_next_level,slide
key.override.field = backend_layout
1 = FILE
1.file = fileadmin/templates/rka2015/main_1_column.html
2 = FILE
2.file = fileadmin/templates/rka2015/main_2_column.html
}
partialRootPath = fileadmin/templates/rka2015/partials/
layoutRootPath = fileadmin/templates/rka2015/layouts/
variables {
siteName = TEXT
siteName.value = rka2015
contentMain < styles.content.get
contentMain.select.where = colPos = 0
content_column_1 < styles.content.get
content_column_1.select.where = colPos = 1
content_column_2 < styles.content.get
content_column_2.select.where = colPos = 2
}
}
First, check out if TYPO3 can read the file by overwriting the page object by appending this to the end of your template:
page.10 >
page.10 = FILE
page.10.file = fileadmin/templates/rka2015/layouts/main_layout.html
If that doesn't generate a page with the raw, uninterpreted output of your template file, then theres something wrong with either the file path or file permissions.
Secondly, in Fluid, Templates and Layouts are different things with different uses and should propably not be put into the same directory.
Most importantly, theres something wrong with the backend layout switch you're trying to build with the CASE in page.10.file.stdWrap.cObject . You see, the stdWrap object actually wraps around the text you've already set. If stdWrap cant find a pipe to figure out how to wrap, it just appends instead. Remove the line where you set the file in the top part and only leave the stdWrap case and you should be good to go.
at the first look it looks right... but check your file paths, maybe they are wrong as "Jost" commented.
i'm not sure but i think the problem is that the template path (file = ...) is the same as layout root path...
by the way... if you include external styles and javascripts you need to set something like the follows i think...
includeJSlibs.jquery = https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
includeJSlibs.jquery.external = 1