从插件模板中检索内容元素字段?
我正在修改插件的模板,并且想从内容元素中检索字段。
使用 f:debug
我发现唯一可用的数据来自插件本身,而没有来自内容元素。
有什么方法可以在插件设置中插入我需要的字段吗?
例如。像这样的东西:
plugin.tx_plugin.settings {
contentUid = TEXT
contentUid.field = uid
}
I am modifying the template of a plugin, and I want to retrieve a field from the content element.
Using f:debug
I see the only data available is from the plugin itself, and none from the content element.
Is there any way I can perhaps insert the field I need in the plugin settings?
eg. something like:
plugin.tx_plugin.settings {
contentUid = TEXT
contentUid.field = uid
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我能想到的最好的方法是使用自定义ViewHelper。类似:
在您的流体模板中:
这将获得内容元素的UID,但是您可以通过这种方式获得任何字段。只需将
数据的密钥更改为所需的字段。
The best way I can think of to do this is with a custom ViewHelper. Something like:
In your Fluid template:
This will get the uid of the content element, but you can get any field this way. Just change the key of the
data
array to the field you need.在相应的方法中(例如
ListAction
或showAction
),您可以通过以下方式获取内容元素的数据:据我所知,您可以't使用Typoscript获取该数据,但是自从我在控制器中使用上述代码以来,我从来都不需要它。
In the corresponding method (like the
listAction
orshowAction
) of the controller you can get the data of the content element in the following way:As far as I know, you can't get to that data using typoscript, but I've never needed it anyway since I've been using the above code in the controller.
设置
没有默认值 stdwrap -type,但只有 string 。因此,您无法将共核用作值。对于一个(或几个)设置,您可以在方法/班级中进行 stdwrap - 处理:
如果您想拥有许多设置,请 stdwrap 查看Ext:新闻。乔治通过” nofollow noreferrer> usestdwrap 配置。
settings
do not have stdWrap-type per default, but only string. So you can not use cObjects as values.For one (or a few) settings, you could do the stdWrap-processing in your method/class yourself:
If you wanna have many settings to be stdWraped, have a look into EXT:news. Georg implemented an interesting concept via useStdWrap configuration.