[TYPO3-dev] Reuse constant in constants.txt

Bernd Wilke t3n at pi-phi.de
Mon Dec 14 12:18:36 CET 2015


Am 14.12.2015 um 09:58 schrieb Florian Rival:
> Hi,
>
> Sure you can, the aim of the constants are there reusability.
>
> With TS, you can define a constant and redefine it later in another part
> of the page tree if needed.
>
> But maybe you want to re-use a constant for another constant, that's not
> possible, you can only use constants in setup TS.

that is not correct.

we always use constants like this:

path.absrefprefix = /
path.fileadmin = {$path.absrefprefix}fileadmin

path.resources = {$path.absrefprefix}typo3conf/ext/my_ext/Resources/Public

path.resources.css = {$path.resources}/CSS
path.resources.css.vendor = {$path.resources.css}/vendor
path.resources.css.pages = {$path.resources.css}/pages
path.resources.javascript = {$path.resources}/Javascript
path.resources.javascript.vendor = {$path.resources.javascript}/vendor
path.resources.javascript.pages = {$path.resources.javascript}/pages
path.resources.images = {$path.resources}/images

you can use constants in the constants part of an template, but not as 
in the setup part.

in the setup field you can use constants in conditions (and also for 
selection of TS-functions/-options *shudder*).
as this is not done reciursively, there are no constants available for 
the conditions which are evaluated for constants part.

keep in mind:
first all involved typoscripts are concatenated (all constants and all 
setup) like you can see it in the template analyzer, then the constants 
part is interpreted and afterwards the setup part

for interpretion all conditions are evaluated (deleting all unused 
parts), then the remaining typoscript gets interpreted.

the interpretation of the setup starts with constants replacement. And I 
think this is done in an iteration (for a fixed number or until all 
constants are resolved?).
in the TSOB you can change the display of constants from 'unsubstituted 
in green' over 'substituted in green' 'resolved' to plain substitution'

for 'substituted in green' the substitution is done only once!
watch the difference if you have constants with constants or constants 
in conditions!


bernd



More information about the TYPO3-dev mailing list