Filtering for seleted categories and subcategories in extbase TYPO3 frontend plugin

23 viewsextbasephptypo3
0

I am using TYPO3 8.7.

I have got an extension which allows to list events. In the list plugin settings the redactor selects the categories. He wants that all events which have the selected category or a subcategory of it assigned are show in the frontend.

I have been reading the documentation on docs.typo3.org and have been looking at the class CategoryCollection. As far as I understand, this class helps me to get the keywords for a certain record, but does not help to select records by a keyword.

I would like to filter also for subcategories because it makes the handling of the extension much easier. Let’s imagine the following event categories:

  • course of studies
    • master’s degree
    • bachaelor’s degree
  • training
    • internal training
    • external training

The backend editor wants to have the choice to display either e.g. internal trainings or all trainings, without activating the parent categories on every event explicitly.

What is the correct way to filter for categories and its subcategories in an extbase repository to display a list of records in the frontend?

Do I have to implement the logic manually to filter for categories and subcategories?