如何在Typoscript 2(Neos)中定义和访问局部变量? [英] How to define and access local variable in Typoscript 2 (Neos)?
问题描述
我已经在Neos中使用自定义TS2文件创建了一个自定义NodeType事件",但是我想这是有关Typoscript 2的一个更普遍的问题.
I have created a custom NodeType "Events" with a custom TS2 file in Neos, but I guess it is more a general question about Typoscript 2.
prototype(Some.Namespace:Events) < prototype(TYPO3.Neos:Document) {
...
sortOrder = ${request.arguments.sortOrder == 'asc' ? 'asc' : 'desc'}
otherVariable = ${sortOrder}
...
}
当然,这可以简化为专注于该问题:
Of course this is simplified to focus on the issue:
我想将变量sortOrder
的值(是"asc"或"desc")分配给另一个名为otherVariable
的变量.
I want to assign the value of the variable sortOrder
(which is "asc" or "desc") to another variable named otherVariable
.
我该怎么做?我无法使用${sortOrder}
访问该值,该值始终返回NULL.
How can I do that? I cannot access the value using ${sortOrder}
, which returns always NULL.
推荐答案
您需要做的就是如下添加this
,并且流体模板中的{otherVariable}
可以使用.如果您有NULL
,请刷新缓存.
All you need to do is add this
as below and {otherVariable}
in your fluid template will work. Flush cache in case you sill have NULL
.
sortOrder = ${request.arguments.sortOrder == 'asc' ? 'asc' : 'desc'}
otherVariable = ${this.sortOrder}
这篇关于如何在Typoscript 2(Neos)中定义和访问局部变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!