Jacco van der Post
Jacco van der Post

Reputation: 618

TYPO3 condition Symfony Expression language on plugin

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.

Upvotes: 1

Views: 401

Answers (3)

tbsschmdt
tbsschmdt

Reputation: 75

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.

Upvotes: 0

Mihir Bhatt
Mihir Bhatt

Reputation: 3155

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

Upvotes: 1

hobsty
hobsty

Reputation: 46

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

Upvotes: 3

Related Questions