after a long time of Google, I can get the categories of FAL Objects in Typo3 7.6 Fluid. But I can only return a String. I want to get an object like {data}.
What I do: TypoScript
lib.category = CONTENT
lib.category {
table=sys_category
wrap=|
select {
pidInList = root,0,1
recursive = 99
max=10
selectFields=sys_category.title,sys_category.uid
join = sys_category_record_mm on sys_category_record_mm.uid_local = sys_category.uid join sys_file_metadata on sys_file_metadata.uid = sys_category_record_mm.uid_foreign join sys_file_reference on sys_file_reference.uid_local = sys_file_metadata.file
where.field = fuid
where.wrap = sys_file_reference.uid=|
}
renderObj=COA
renderObj {
1=TEXT
1.field = uid
2=TEXT
2.field = title
}
}
In Fluid I have:
<f:for each="{files}" as="file">
<p>
- {file.uid}<br />
- <f:cObject typoscriptObjectPath="lib.category" data="{fuid:file.uid}" />
</p>
</f:for>
On the webpage it prints:
- 88
3Black7Small
89
2Blue7Big
90
- 1Red
But I think an object in Fluid is better, so I can use f:for each etc. But I don't know how I can return it.
Can anybody help me?
Looks like this task is very tricky. The
file
object in the{files}
array is of type\TYPO3\CMS\Core\Resource\FileReference
where properties like uid, title or description are passed through from the original file object of type\TYPO3\CMS\Core\Resource\File
.FileReference
is actually implemented as a model but not file, so you can not extend it.The only other way i see is to create a viewhelper that will get the categories with a native sql query and the CategoryRepository would automatically map the result to the Category model. Something like that:
I have not tested the actual code, only the sql query, but this should work. Also i hope that you know how to include viewhelpers in your fluid template, if not I will provide an example.