Typoscript approvements in TYPO3 >4
Ok this is a bit late, but I recently noticed that there are some improvements in the TypoScript language: You can use the new operator ":=" in combinition with some functions.
This is especially very helpful to manipulate liststrings, e.g. to adjust configuration of the RTE.
I just copy and paste the relevant section from
Value modifications: The ":="-operator
assigns a value to an object path by calling a predefined function which modifies the existing value of the current object path in different ways.
This is very useful for extending lists of page IDs etc. when a value should be extended without redefining it completely again.
- The portion after the “:=”-operator and to the end of the line is split in two parts: A function and a value. The function is specified right next to the operator (trimmed) and holding the value in brackets (not trimmed).
- There are four predefined functions:
- prependString: Adds a string to the beginning of the existing value.
- appendString: Adds a string to the end of the existing value.
- removeString: Removes a string from the existing value.
- replaceString: Replaces old with new value. Separate these using “|”.
- addToList: Adds a comma-separated list of values to the end of a string value. There is no check for duplicate values, and the list is not sorted in any way.
- removeFromList: Removes a comma-separated list of values from a comma-separated list.
There is a hook inside class.t3lib_tsparser.php which can be used to define more functions like this.
myObject = TEXT
myObject.value = 1,2,3
myObject.value := addToList(4,5)
myObject.value := removeFromList(2,1)
...results in the same like this:
myObject = TEXT
myObject.value = 3,4,5