Display System Categories in TYPO3-FE

1.3k views Asked by At

I am trying to build my first own extension with the Extension Builder. Up to now everything worked really well, but now I've got a problem and am not able to find a solution:

My extension looks like this: You can add new Entries in the backend under List (the entry on the right panel). These entries are then shown in the frontend. While adding new entries there is the possibility in the horizontal navigation bar to link this entry to specific categories. I've already done this with every entry. But how can I display this category in the fronted. It should be just one <div> like Linked Categories: CATEGORY. It seems like there is no ViewHelper which can display all linked categories.

I've already googled a lot, but this just confused me more: It seems like its not possible with a simple ViewHelper. There was a solution, where one had to edit the controller. But I did not like this because then I can not continue working with the Extension Builder or it becomes overwritten. I also looked in the code of tx_news. It seems like all categories are in a variable there, which can be looped. But in my extension <f:debug>{categories} was always NULL.

Is there no ViewHelper which can display the categories, or anything else? Maybe a good tutorial (I am good in PHP, but new to TYPO3).

Thank you very much in advance, Felix

P.S: I am using TYPO3 CMS 7.6.9

1

There are 1 answers

0
rob-ot On

the Extension Builder is just a 'kickstarter' that helps you define your models and actions, relations etc ... It will not do more then that. So once you created your extension draft, it's best to forget about the extension builder and try to understand the structure of an extbase extension (the MVC, TCA, localconfig, typoscript,...). If you need to add a new property, do it manually. You will learn a lot more about your extension and how it works.

Having this said, you will have to adjust your extansion yourself to add categories. There are a few ways to do it: you can add your own category system by adding your own category Model, or use the TYPO3 category API https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Categories/Index.html

There is also no plug&play category viewhelper. If you like to be able to list your entries by category, you will need to adjust your controller. You can add some functionality to an existing on, for ex. your listAction so that it reads arguments send to this action (a list of categories you like to filter on) or create a new one called for example categoryAction.

extbase reference : https://docs.typo3.org/typo3cms/ExtbaseFluidBook/b-ExtbaseReference/Index.html

stackoverflow question about categories in a controller: Controllers and Template (how to filter results correctly or give arguments via backend?)

bottom line: - skip extension builder - learn how to adjust the MVC yourself

you can always join the TYPO3 slack channel : https://typo3.slack.com/ it's free and people are very helpfull

good lcuk