The content on this page is no longer maintained and may be out of date.

Category API

Since version 6.0 TYPO3 offers an API to make the use of categories in own extensions possible with little effort.

To activate the categories for a model of your own extension or an existing extension, the following code must be added to the corresponding file in the directory Configuration/TCA/Overrides/ of the extension. Please always put this code in the overrides and not in the TCA/file.


    'categories' // this parameter is optional! default value is categories



In the first parameter we pass the extension key. Second, the table name of the model. The following additional parameters can be added as an option: Third parameter: Field name in the model table for categories. Fourth parameter: Optional configuration. Fifth parameter: Overwrite and delete old configuration.

After adding the code, a Database Compare must be performed using the Install Tool or alternatively the extension must be deactivated and reactivated using the Extension Manager to add the new field.

Category API extbase frontend usage

The next step is the frontend usage. We´ll an extbase based AbstractEntity as example domain model.



namespace Kronovanet\MyExt\Domain\Model;

use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

class Example extends AbstractEntity
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\Category>
    protected $categories;

    public function __construct()
        $this->categories = new ObjectStorage();

     * @return ObjectStorage
    public function getCategories(): ObjectStorage
        return $this->categories;
     * @param ObjectStorage $categories
    public function setCategories(ObjectStorage $categories)
        $this->categories = $categories;


Now we are ready to use those categories for everything we want.

Fluid template example (GitHub)

Use categories inside a FlexForm

If you want to define an output in your plugin using categories via the settings, you can also use categories as settings in a FlexForm.


Notice: You can define the settings name as you want. You aren´t forced to name it "categories".


    <foreign_table_where> AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.sorting ASC</foreign_table_where>


Then you can use the user input inside your controller with $this->settings['categories'] or in your fluid template {settings.categories}.


No Comments

Write comment

* These fields are required