Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typo3 using constants in "Constant" field

I want to form file path. In "Constant" field:

const.siteName = site
templates = fileadmin/templates/{$const.siteName}/

When i look in typoscript object browser:

[siteName] = site    
[templates] = fileadmin/templates/{$const.siteName}/

Is it possible to achieve this:

[templates] = fileadmin/templates/site/

using const.siteName?

If yes, how?

=========================================================================

EDIT:

What i am tying to do is next:

In my extension configuration

const.siteName = foo
const.templates = fileadmin/templates/($const.siteName)/
const.path.extensions = ($const.templates)/ext/

I include my extension in typoscript template. In my extension setup i include setup for plugin like this:

<INCLUDE_TYPOSCRIPT: source="FILE:EXT:foo/Configuration/TypoScript/Plugin/formhandler.ts">

In Configuration/TypoScript/Plugin/formhandler.ts:

plugin.Tx_Formhandler {
    /* snip */
    settings.predef.member {
        templateFile.value = {$const.path.extensions}formhandler/member/step-1.html // doesn't work
        //templateFile.value = fileadmin/templates/foo/ext/formhandler/member/step-1.html // works
    }
    /* snip */
}
like image 698
Evil Penguin Avatar asked Dec 19 '22 13:12

Evil Penguin


2 Answers

For me, this example works perfect:

Constants:

const.test = foo
const.test2 = {$const.test}/bar

Setup:

page = PAGE

page.10 = TEXT
page.10.value = {$const.test}
page.10.wrap = <p>|</p>

page.20 = TEXT
page.20.value = {$const.test2}
page.20.wrap = <p>|</p>

Output in Browser:

foo

foo/bar

Tested with TYPO3 4.5 and 8.3

like image 107
Peter Kraume Avatar answered Dec 21 '22 04:12

Peter Kraume


Have a look at the TYPO3 NG/ML/Forum:

https://forum.typo3.org/index.php?t=msg&th=212721&goto=740111&#msg_740111 there are a lot of hints how to use constants in typoscript:

you can reuse constants in constants definition, but only up to 10 levels deep.

you can use constants in conditions, but only in setup-part

like image 32
Bernd Wilke πφ Avatar answered Dec 21 '22 02:12

Bernd Wilke πφ