TYPO3-如何正确定义常量,将其存储到变量中并在流体模板内部使用 [英] TYPO3 - how to properly define constant, store it into variable and use inside of fluid template

查看:48
本文介绍了TYPO3-如何正确定义常量,将其存储到变量中并在流体模板内部使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在使用的插件的Fluid模板中,有些东西是硬编码的.例如:

In the Fluid template of plugin I am working on, some things are hardcoded. For instance:

<f:else>
                <li>
                    <v:page.link pageUid="114" />
                </li>
            </f:else>

由于 pageUid 的值在测试服务器和生产服务器上不相同,因此我想使其更具动态性.

Since pageUid values are not same on test and production server I would like to make this more dynamic.

我想以某种方式将其存储在变量中,然后在流体模板中使用该变量.

I would like to store this somehow in variable and then use the variable in the fluid template.

我只是不知道该在TYPO3中做什么.

I just dont know hot to make this and where in TYPO3.

提前谢谢!

推荐答案

因为它是一种设置,所以请执行以下操作:

Because it is an setting do it like this:

常量:

plugin.myext.settings.detailPid = 123

设置:

plugin.myext.settings.detailPid = {$plugin.myext.settings.detailPid}

变量用于变量内容.如果您使用的变量与TEXT或类似变量具有相同的PID,则建议改写,并且设置是正确的方法.

Variables are for variable content. If you have the same PID using variables with TEXT or similiar is overdressed and settings are the correct way.

变量只能访问FLUID_TEMPLATE内容元素,而不能访问插件!

此外,您还可以在extbase控制器中通过简单访问 $ this-> settings ['detailPid'] 来访问这些设置,而无需首先呈现cObject.

Also in your extbase controller you can access these settings by simple access $this->settings['detailPid']without to render the cObjects first.

在流体中,您可以通过 {settings.detailPid} 访问设置.

In your fluid you can access settings by {settings.detailPid}.

这篇关于TYPO3-如何正确定义常量,将其存储到变量中并在流体模板内部使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆