Search code examples
typo3typo3-7.6.xtx-news

Category shown in list-view


is there a way to setup categories in a way that Category1 is only shown when there are no other categories selected.

Currently it shows the category which has been selected first.

Category1 + Category2 shows Category1
Category2 + Category1 shows Category2

Thanks

EDIT:
Typo3 Version: 7.6.23
News Version: 6.1.1


Solution

  • anaylyzing the news template ext:news/resources/Private/Partials/List/Item.html you will find this fluid code:

    <f:if condition="{newsItem.firstCategory}">
        <!-- first category -->
        <span class="news-list-category">{newsItem.firstCategory.title}</span>
    </f:if>
    

    Which will only show one category (probably the first one)

    if you want all categories have a look into the detail-view (ext:news/Resources/Private/templates/News/Detail.html):

    <f:if condition="{newsItem.categories}">
        <f:render partial="Category/Items" arguments="{categories:newsItem.categories, settings:settings}" />
    </f:if>
    

    copy the item partial from list view into your space (extensions) and modify the category inclusion by replacing it from the detail view.
    Additionally you can add a logic to skip the Category1.