[TYPO3-core] RFC: Extend TypoScript values
Michael Stucki
michael at typo3.org
Sat Mar 4 03:13:35 CET 2006
Michael Stucki wrote:
> Finally committed! :-)
> I still have to document this in doc_core_ts, will do that next week.
This is my proposed documentation:
doc_core_ts, section "TypoScript Syntax":
=== cut ===
Operator is one of the characters =<>{( (Above: =). The significance of each
is described below.
=== cut ===
Just add one sentence:
There is one special operator ":=" that changes the value depending on a
predefined function.
... and some lines down, right after the description of the "=" operator:
=== cut ===
Value modifications: The ":="-operator
assigns a value to an object path by calling a predefined function and based
on the existing value of the current object path.
This is very useful for extending lists of page IDs etc. when a value should
be extended without redefining it completely again.
Rules:
- 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:
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.
addString:
Adds a string to the end of the existing value.
removeFromList:
Removes a comma-separated list of values from a comma-separated list.
removeString:
Removes a string from the existing value.
- There is a hook inside class.t3lib_tsparser.php which can be used to
define more functions like this.
Example:
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
=== cut ===
If nobody declines, I will commit this change tomorrow.
Regards, michael
--
Use a newsreader! Check out
http://typo3.org/community/mailing-lists/use-a-news-reader/
More information about the TYPO3-team-core
mailing list