I have to render all results of the query, not just one. At the moment I only receive the first results of that query and the result stays the same for all 3 calls.
Here is the template/partial which gets called for every page:
<div class="item">
<f:debug>{_all}</f:debug>
<f:link.page pageUid="{page.data.uid}" target="{page.data.target}" title="{page.data.title}">
<h3 class="title">{page.data.title}</h3>
<h4>{page.data.uid}</h4>
<h3><f:cObject typoscriptObjectPath="lib.category" data="{page.data}" /></h3>
</f:link.page>
</div>
The important call is this one:
<f:cObject typoscriptObjectPath="lib.category" data="{page.data}" />
Here is the TypoScript to get all the categories
lib.category = CONTENT
lib.category {
table=sys_category
wrap=|
select {
pidInList = root
selectFields = sys_category.*
join = sys_category_record_mm ON sys_category_record_mm.uid_local = sys_category.uid
where.field = sys_category_record_mm.uid_foreign = uid
languageField = 0
}
renderObj = COA_INT
renderObj {
1 = TEXT
1.field = title
}
}
The important line is:
where.field = sys_category_record_mm.uid_foreign = uid
= uid is the uid we pass in <f:cObject...
.
and here is the part that actually renders the string with the category title (just one at the moment, even if more categories are set)
renderObj = COA_INT
renderObj {
1 = TEXT
1.field = title
}
So 2 problems:
How should I rework that TypoScript/template to ensure that I get a full list (can be a string) of assigned categories from that specific page?
Sadly, you will need to write your own ViewHelper to do this. The default core "API" offers no support for categories. Also, it seems, this is not planned for the very useful vhs extension, as a feature request for exactly this has been closed.
Luckily, you can copy&paste a solution from someone else. The solution in fluid then looks like:
<f:if condition="{data.categories}">
<f:for each="{my:CategoriesOutput(recUid: data.uid)}" as="category">
<span class="{category.slug}">{category.title}</span>
</f:for>
</f:if>