简体   繁体   中英

Display all categories from news item

I have a news item that has more categories. If I use firstCategory then I receive as output the first chosen category, but it's not what I want. I want to display all the categories that a news item has been marked as. I've tried following but there is no output

<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>

In for loop use newsItem.categories instead of categories . Like below.

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM