Evil Penguin
Evil Penguin

Reputation: 114

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 */
}

Upvotes: 4

Views: 1961

Answers (3)

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10800

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

Upvotes: 5

Peter Kraume
Peter Kraume

Reputation: 3812

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

Upvotes: 8

rob-ot
rob-ot

Reputation: 1264

short : NO

long: you can only use constants in your setup.

what you can do is:

CONSTANTS

const.siteName = site
const.templatePath = fileadmin/templates

SETUP:

myTemplate= {$const.templatePath}/{$const.siteName}

Upvotes: 0

Related Questions