如何在流体中访问FileReference对象的属性 [英] How to access properties of a FileReference Object in fluid
问题描述
在下面,您将看到流体中FileReference类型的对象的调试.流畅的调试看起来像这样:<f:debug>{fileReference}</f:debug>
Below you see the debug for an object of type FileReference in fluid. In fluid the debug looks like this: <f:debug>{fileReference}</f:debug>
问题是如何访问以绿色突出显示的属性,分别为width
,height
和hovertext
.
The question is how do I access the properties highlighted in green, being width
, height
, and hovertext
.
原始文件是图片,因此width
& height
是默认的T3属性,hovertext
已由我的扩展程序添加,它具有自己的getter/setter.
The original file is an image, so width
& height
are default T3 properties, hovertext
has been added by my extension with it's own getter/setter.
我尝试了以下操作:
{fileReference.width}
{fileReference.mergedProperties.width}
{fileReference.originalResource.width}
到目前为止没有运气,访问mergedProperties
中的值的正确方法是什么?
No luck so far, what is the right way to access the values in mergedProperties
?
非常感谢
弗洛里安
推荐答案
f:debug
显示的内容类似于var_dump
函数,因此显示对象的属性.在Fluid中,您只能访问getter函数,如果是数组,则为数组的值.因此,如果您编写类似{fileReference.mergedProperties}
的内容,则调用getMergedProperties()
(如果存在)的方法.
The f:debug
shows something similar to the var_dump
function, so the properties of an object. In fluid you can only access the getter functions or if it is an array the values of the array. So if you write something like {fileReference.mergedProperties}
the method getMergedProperties()
is called if it is present.
知道您可以查看sysext/core/Classes/Resource/FileReference.php
文件的内部,并查看其具有的吸气剂.我们可以快速找到public function getProperties()
返回您标记的合并属性,因此正确的解决方案应该是:
Knowing that you can look inside the sysext/core/Classes/Resource/FileReference.php
File and see what getters it has. We can quickly find the public function getProperties()
that returns the merged properties you marked, so the right solution should be this:
{fileReference.properties.width}
这篇关于如何在流体中访问FileReference对象的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!