Typo3在"常量"字段中使用常量

Evi*_*uin 3 typo3 typoscript

我想形成文件路径.在"常量"字段中:

const.siteName = site
templates = fileadmin/templates/{$const.siteName}/
Run Code Online (Sandbox Code Playgroud)

当我查看typoscript对象浏览器时:

[siteName] = site    
[templates] = fileadmin/templates/{$const.siteName}/
Run Code Online (Sandbox Code Playgroud)

是否有可能实现这一目标:

[templates] = fileadmin/templates/site/
Run Code Online (Sandbox Code Playgroud)

const.siteName

如果有,怎么样?

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

编辑:

接下来我要做的是:

在我的扩展配置中

const.siteName = foo
const.templates = fileadmin/templates/($const.siteName)/
const.path.extensions = ($const.templates)/ext/
Run Code Online (Sandbox Code Playgroud)

我将我的扩展包含在typoscript模板中.在我的扩展程序设置中,我包含这样的插件设置:

<INCLUDE_TYPOSCRIPT: source="FILE:EXT:foo/Configuration/TypoScript/Plugin/formhandler.ts">
Run Code Online (Sandbox Code Playgroud)

在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 */
}
Run Code Online (Sandbox Code Playgroud)

Pet*_*ume 8

对我来说,这个例子很完美:

常量:

const.test = foo
const.test2 = {$const.test}/bar
Run Code Online (Sandbox Code Playgroud)

建立:

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>
Run Code Online (Sandbox Code Playgroud)

浏览器输出:

foo

foo/bar
Run Code Online (Sandbox Code Playgroud)

用TYPO3 4.5和8.3测试

  • @EvilPenguin不要在你的一个代码示例中使用`()`但是`{}`来表示你的错误. (4认同)
  • 但是,TypoScript Objectbrowser无法解析常量部分中的常量.不过,前端的使用效果还不错! (2认同)

Ber*_* πφ 5

看看 TYPO3 NG/ML/论坛:

https://forum.typo3.org/index.php?t=msg&th=212721&goto=740111&#msg_740111 有很多关于如何在打字稿中使用常量的提示:

您可以在常量定义中重用常量,但最多只能重用 10 层。

您可以在条件中使用常量,但只能在设置部分中使用