0

I'll try to design my own content elements with DCE (Dynamic Content Elements). The problem I have a problem when I try to work with images. I created a select field for images which works fine. In the fluid template I have the following code for handling the image:

<f:image src="{field.image}" alt="" treatIdAsReference="1" />

But if I try to insert the content element, Typo3 throws me this exeption:

Oops, an error occurred!

No file usage (sys_file_reference) found for given UID.

More information regarding this error might be available online.

I already found out, that this is pretty sure a bug in Typo3, but how can I fix it?

Oliver Hader
  • 4,093
  • 1
  • 25
  • 47
Marcel
  • 627
  • 7
  • 25

3 Answers3

1

Check This Tutorial and set it accordingly. http://docs.typo3.org/typo3cms/extensions/dce/Tutorial/Index.html Your problem might be solved...!!

vijay rami
  • 535
  • 4
  • 19
1

Got it. With the hint form vijay rami I found out, that you have to render images in dce like this:

<f:for each="{dce:fal(field:'image', contentObject:contentObject)}" as="fileReference" iteration="iterator">
    <f:if condition="{iterator.isFirst}">
        <f:image src="{fileReference.uid}" alt="" treatIdAsReference="1" />
    </f:if>
</f:for>

Of course you have to edit in the first line "field:'image'" to your name.

Community
  • 1
  • 1
Marcel
  • 627
  • 7
  • 25
1

For the Template use this code:

<f:for each="{dce:fal(field:'fal', contentObject:contentObject)}" as="fileReference" iteration="iterator">
    <f:if condition="{iterator.isFirst}">
        <f:image src="{fileReference.uid}" alt="" treatIdAsReference="1" />
    </f:if>
</f:for>

Notice field:'fal' is not the variable name you set, it's part of the configuration below the variable name:

...
<foreign_match_fields>
    <fieldname>fal</fieldname> <!-- Name of variable! -->
</foreign_match_fields>
...
PeterTheOne
  • 343
  • 6
  • 15
  • 1
    I can confirm that this works. It's a little bit confusing, because you might think "field:" is the field name. Maybe it's intended to be, but doesn't work like this in this case. – Florian Rachor Jul 29 '15 at 10:47