显示新闻项目的所有类别

Display all categories from news item

我有一个包含更多类别的新闻。如果我使用 firstCategory,那么我会收到第一个选择的类别作为输出,但这不是我想要的。我想显示一个新闻项目被标记为的所有类别。我试过以下但没有输出

<f:if condition=“{newsItem.categories}“>
    <span class=“news-list-category label label-default test”>
       <f:for each=“{categories}” as=“category”>
               {category.title}
       </f:for>
    </span>
</f:if>

在 for 循环中使用 newsItem.categories 而不是 categories。如下所示。

<f:if condition=“{newsItem.categories}“>
    <span class=“news-list-category label label-default test”>
       <f:for each=“{newsItem.categories}” as=“category”>
               {category.title}
       </f:for>
    </span>
</f:if>