How to access properties of a FileReference Object in fluid

自古美人都是妖i 提交于 2019-12-21 09:32:53

问题


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>

The question is how do I access the properties highlighted in green, being width, height, and hovertext.

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.

I tried the following:

{fileReference.width}
{fileReference.mergedProperties.width}
{fileReference.originalResource.width}

No luck so far, what is the right way to access the values in mergedProperties?

Many Thanks

Florian


回答1:


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.

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}


来源:https://stackoverflow.com/questions/40135241/how-to-access-properties-of-a-filereference-object-in-fluid

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