Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
System categories
TYPO3 provides a generic categorization system. Categories can be created in the backend like any other type of record.
A TCA field of the column type category is available.
Pages, content elements and files contain category fields by default.
Changed in version 11.4
Starting with v11.4 the formerly used PHP function
Extension
is deprecated and
removed with v12.0. Use a TCA field of the type
category instead.
Using Categories
Managing Categories
System categories are defined like any other record. Each category can have a parent, making a tree-like structure.
The Items tab shows all related records, for example all records that have been marked as belonging to this category.
Adding categories to a table
Deprecated since version 11.4
Starting with v11.4 Defining category fields for tables with
$GLOBALS
or
by calling Extension
is
deprecated.
Categories can be added to a table by defining a TCA field of the TCA column type category. While using this type, TYPO3 takes care of generating the necessary TCA configuration and also adds the database column automatically. Developers only have to configure the TCA column and add it to the desired record types:
$GLOBALS['TCA'][$myTable]['columns']['categories'] = [
'config' => [
'type' => 'category'
]
];
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
$myTable,
'categories'
);
This is the result of the above code:
Using categories in FlexForms
It is possible to create relations to categories also in FlexForms.
Due to some limitations in FlexForm, the property
relationship
many
is not supported. Therefore, the default value for this property
is one
.
<T3DataStructure>
<ROOT>
<TCEforms>
<sheetTitle>aTitle</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<categories>
<TCEforms>
<config>
<type>category</type>
</config>
</TCEforms>
</categories>
</el>
</ROOT>
</T3DataStructure>
System categories API
Deprecated since version 11.4
Starting with v 11.4 the API function
Extension
and the class
Category
have been deprecated.
Use a TCA field of the type category instead.
Category Collections
The \TYPO3\
class provides the API for retrieving records related
to a given category. It is extended by class
\TYPO3\
which does the same job but in the frontend, i.e.
respecting all enable fields and performing version
and language overlays.
The main method is load
which will return a
traversable list of items related to the given category.
Here is an example usage, taken from the RECORDS content object:
$collection = \TYPO3\CMS\Frontend\Category\Collection\CategoryCollection::load(
$aCategory,
true,
$table,
$relationField
);
if ($collection->count() > 0) {
// Add items to the collection of records for the current table
foreach ($collection as $item) {
$tableRecords[$item['uid']] = $item;
// Keep track of all categories a given item belongs to
if (!isset($categoriesPerRecord[$item['uid']])) {
$categoriesPerRecord[$item['uid']] = [];
}
$categoriesPerRecord[$item['uid']][] = $aCategory;
}
}
As all collection classes in the TYPO3 Core implement the
Iterator
interface, it is also possible to use expected methods like
next
, rewind
, etc. Note that methods such as
add
will only add items to the collection temporarily.
The relations are not persisted in the database.
Usage with TypoScript
In the frontend, it is possible to get collections of categorized records loaded into a RECORDS content object for rendering. Check out the categories property.
The HMENU object also has a "categories" special type to display a menu based on categorized pages.
User permissions for system categories
In most aspects, system categories are treated like any other record. They can
be viewed or edited by editors if they are stored in a folder where the editor
has access to and if the table sys_
is allowed in the field
Tables (listing) and Tables (modify) in the tab
Access Lists of the user group.
Additionally it is possible to set Mounts and Workspaces > Category Mounts in the user group. If at least one category is set in the category mounts only the chosen categories are allowed to be attached to records.