TSrefConstants
From TYPO3Wiki
| TypoScript Referenz - Constants |
|
||||
This page is document in progress. TypoScript
Constants
Constants are values defined in the "Constants"-field of a template. They follow the syntax of ordinary TypoScript!
NOTE, reserved name: The object or property "file" is always interpreted as data type "resource".
NOTE: Toplevel "object" TSConstantEditor cannot be used. It's reserved for configuration of the ConstantEditor module (Changed from beta4) Example:
Here "bgCol" is set to "red" and "file.toplogo" is set to "logo*.gif" which is found in the resource-field of the template.
bgCol = red topimg.width = 200 topimg.file.pic2 = fileadmin/logo2.gif file.toplogo = logo*.gif
This could also be defined like this:
bgCol = red
file {
toplogo = logo*.gif
}
topimg {
width = 200
file.pic2 = fileadmin/logo2.gif
}
Inserting constants
Constants are inserted in the template-setup by performing an ordinary str_replace operation! You insert them like this:
{$bgCol}
{$topimg.width}
{$topimg.file.pic2}
{$file.toplogo}
Example:
page = PAGE
page.typeNum = 0
page.bodyTag = <body bgColor="{$bgCol}">
page.10 = IMAGE
page.10.file = {$file.toplogo}
Only defined constants are substituted.
Constants in included templates are also substituted as the whole template is just on large chunk of text.
Constants are case sensitive.
You should use a systematic naming of constants. Seek inspiration in the code-examples around.
Notice how the constants in the setup code is substituted. In the Object Browser, you can monitor the constants with or without substitution. Also notice that the value "logo*.gif" was resolved to the resource "uploads/tf/logo_01.gif"
