codefog/contao-news_categories

Display subcategories in news templates

Opened this issue · 1 comments

This page explains how to display all categories in a news template.
https://github.com/codefog/contao-news_categories/blob/master/docs/template-adjustments.md

Is it also possible to display only the categories from a subcategory in this way?

For example only the categories from the subcategorie Sports
Bildschirmfoto 2022-03-11 um 14 36 54

Hey there, dont know if this is relevant anymore - but maybe you can do this with the NewsCategory Model?
https://github.com/codefog/contao-news_categories/blob/master/src/Model/NewsCategoryModel.php

use Codefog\NewsCategoriesBundle\Model\NewsCategoryModel;

$sportsCategory = NewsCategoryModel::findPublishedByPid(1); // or other id from the main category

Then fetch the data and loop through it. Not tested btw ;-)