How to define and access local variable in Typoscript 2 (Neos)?

為{幸葍}努か 提交于 2019-12-12 02:12:01

问题


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:

I want to assign the value of the variable sortOrder (which is "asc" or "desc") to another variable named otherVariable.

How can I do that? I cannot access the value using ${sortOrder}, which returns always NULL.


回答1:


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}


来源:https://stackoverflow.com/questions/41614063/how-to-define-and-access-local-variable-in-typoscript-2-neos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!