TYPO3 condition Symfony Expression language on plugin - typo3

How can I write this old style typoscript condition in Symfony Expression language?
[globalVar = GP:tx_myext_myplugin|bla > 0]
Perhaps something like
[request.getQueryParams()['tx_myext_myplugin[bla]'] > 0]
but that is obvious not working.

[(request.getQueryParams()['tx_myext_myplugin'])['bla'] > 0]

In case it is generating an error inside log then you need to check like this.. (i.e. Unable to get an item on a non-array)
[request.getQueryParams() and
request.getQueryParams()['tx_myext_myplugin'] and
request.getQueryParams()['tx_myext_myplugin']['bla'] > 0]
//Typoscript Code
[end]
&& can also be used as conditional operator here

The old style TypoScript condition [globalVar = GP:tx_myext_myplugin|bla > 0] can be written with new condition syntax like [traverse(request.getQueryParams(), 'tx_myext_myplugin/bla') > 0].
Use traverse in combination with getQueryParams to avoid errors in case a key in the parameter array is not defined.

Related

Typoscript condition with new symfony expression syntax

Anybody here who knows how to write this TS condition in the new symfony expression syntax?
[globalVar = TSFE:sys_page|versioningWorkspaceId = 1]
Or is there any other way to find out if one is viewing a workspace?
Thanks in advance!
the desired syntax is:
[getTSFE().sys_page.versioningWorkspaceId == '1']
As a rule of thumb,
Arrays should be written with brackets,
Objects are written with points.

TypoScript Conditions with Literals

I am experiencing a strange behaviour. I have a TYPO3 7.6.18 and a TS condition like shown on https://docs.typo3.org/typo3cms/TyposcriptReference/Conditions/Reference/Index.html#id45
Constants:
testswitch = 1
Setup:
testvar = {$testswitch}
[globalVar = LIT:1 = {$testswitch}]
testvar = 99
[global]
I expect testvar to be 99, but instead it is 1 (checked via TypoScript Object Browser). Any explanation? What am I doing wrong? Is this a TYPO3 bug?
In the TypoScript Object Browser is a list of conditions at the bottom. You have to actually activate the specific condition, for it to take effect, otherwise it won't show up as expected in the tree.
Edit addition: That also means that testing conditions in the Object Browser does not necessarily help. Setting the checkbox will evaluate the condition as true, regardless of whether the condition would actually be true if evaluated normally in frontend.

Typoscript Condition: backend_layout (with slide)

I use this condition
[globalVar = GP:colPos==0]&&[page|backend_layout = pagets__MainTemplate]
My problem is that my „subpage“ has no backend_layout selected because the parent pages "Backend Layout (subpages of this page)“ is set. So the condition does not work on subpages.
Can create a condition like that?
lib.backendLayout = TEXT
lib.backendLayout {
data = levelfield:-1, backend_layout_next_level, slide
override.data = TSFE:page|backend_layout
}
I want do white/blacklist CTypes in BE Columns in this way:
[globalVar = GP:colPos==0]&&[page|backend_layout = pagets__MainTemplate]
TCEFORM.tt_content.CType.keepItems := addToList(header)
[end]
Not as far as I know, as you can only access the current page record with the "page" condition.
Instead you could
a) Write your own condition (see https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/Conditions/Reference/Index.html#custom-conditions or starting with version 9 https://docs.typo3.org/typo3cms/TyposcriptReference/Conditions/Reference.html#extending-the-expression-language-with-own-functions-like-old-userfunc)
b) Use a userFunc (like "a" only older and less fancy ;)) - see https://docs.typo3.org/typo3cms/TyposcriptReference/8.7/Conditions/Reference/Index.html#userfunc
new c) follow Jigals suggestion (or use a similar extension - there are a few - but they mostly do a lot more than what you need)
--- EDIT after question update ---
As you want it working in TSConfig c) is actually not an option.
c) depending on what you actually want to achieve with your condition use if and data (like in your description) directly at the TS objects that should have different behavior if your condition is true.
For reference:
Differences between TSConfig Conditions and TS Conditions:
https://docs.typo3.org/typo3cms/TSconfigReference/8.7/Conditions/Index.html#differences-to-conditions-in-typoscript-templates
As an alternative to Susi's solutions you could use Gridelements. This extension has the feature that you can set inside each block in a backend layout which CEs are allowed.

In TYPO3 6.1 fluid, how to correctly write conditions in a Partial?

In my extbase/fluid extension, I can get "if" conditions to work in a List template, but not in a Partial.
<f:if condition="item.label == 0">xxx</f:if>
returns true and writes out "xxx" no matter what item.typ's value is.
Is that the right syntax for a condition in a partial?
Got it. The field name needs to be in curly brackets:
<f:if condition="{item.label} == 0">xxx</f:if>

Allow HTML in TYPO3 Subheader

I couldn't find anything about this on the web or in the documentation, so I wonder if it's possible.
lib.stdheader.10.setCurrent.htmlSpecialChars = 0
Works fine for standard header and I already tried
lib.stdheader.20.setCurrent.htmlSpecialChars = 0
for subheader, but doesn't work.
Any hint is very appreciated!
Take a look at TypoScript Object Browser in Template module.
You'll see, that lib.stdheader.20 doesn't have setCurrent property. Instead it has bunch of properties, like 1., 2., ... and default. All of them correspond to header type: h1, h2, h3 etc. and default (which is h2).
So, you need to override htmlSpecialChars for each of them. Or, at least, for default, if you're not planning to use different subheader types:
lib.stdheader.20.1.htmlSpecialChars = 0
lib.stdheader.20.2.htmlSpecialChars = 0
...
lib.stdheader.20.default.htmlSpecialChars = 0
Try this one :-
For headers :
lib.stdheader.10.setCurrent.htmlSpecialChars >
For subHeaders :
lib.stdheader.20.setCurrent.htmlSpecialChars >