Skip to content

Commit

Permalink
[TASK] Overhaul category type (#995)
Browse files Browse the repository at this point in the history
* [TASK] Overhaul category type

* Correct indentation,
* add names for confvals

releases: main, 12.4, 11.5

* Update Documentation/ColumnsConfig/Type/Category/Properties/ForeignTablePrefix.rst

Co-authored-by: Chris Müller <[email protected]>

---------

Co-authored-by: Chris Müller <[email protected]>

(cherry picked from commit 1c03d51)
  • Loading branch information
linawolf committed Mar 26, 2024
1 parent 08bad8a commit 76f2eba
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 157 deletions.
18 changes: 9 additions & 9 deletions Documentation/ColumnsConfig/Type/Category/Examples.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
.. include:: /Includes.rst.txt
.. _columns-category-examples:
.. include:: /Includes.rst.txt
.. _columns-category-examples:

========
Examples
========

.. _columns-category-simple-example:
.. _columns-category-simple-example:

Simple category field
=====================

In the following example a category tree is displayed and multiple categories
can be selected.

.. include:: /CodeSnippets/Manual/CategorySimple.rst.txt
.. include:: /CodeSnippets/Manual/CategorySimple.rst.txt


The relationship gets stored in the intermediate table
:sql:`sys_category_record_mm`. Category counts are only stored on the
local side.

.. note::
This is the use case, which was previously accomplished using
:php:`ExtensionManagementUtility->makeCategorizable()` up to v11.
.. note::
This is the use case, which was previously accomplished using
:php:`ExtensionManagementUtility->makeCategorizable()` up to v11.


One to one relation category field
Expand All @@ -31,7 +31,7 @@ One to one relation category field
In the following example a category tree is displayed, but only one
category can be selected.

.. include:: /CodeSnippets/Manual/CategoryOneTo.rst.txt
.. include:: /CodeSnippets/Manual/CategoryOneTo.rst.txt


Category field used in FlexForm
Expand All @@ -45,4 +45,4 @@ is `oneToMany`.
An example of the "oneToMany" use case is EXT:news,
which allows to only display news of specific categories in the list view:

.. include:: /CodeSnippets/Manual/CategoryFlexform.rst.txt
.. include:: /CodeSnippets/Manual/CategoryFlexform.rst.txt
45 changes: 22 additions & 23 deletions Documentation/ColumnsConfig/Type/Category/Index.rst
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
.. include:: /Includes.rst.txt
.. include:: /Includes.rst.txt

.. _columns-category:
.. _columns-category:

========
Category
========

.. versionadded:: 11.4
The TCA field type called `category` has been added to TYPO3 Core. Its main
purpose is to simplify the TCA configuration when adding a category
tree to a record. It therefore supersedes the :php:`CategoryRegistry` as well
as the :php:`ExtensionManagementUtility->makeCategorizable()`, which has required
creating a "TCA overrides" file.
.. versionadded:: 11.4
The TCA field type called `category` has been added to TYPO3 Core. Its main
purpose is to simplify the TCA configuration when adding a category
tree to a record. It therefore supersedes the :php:`CategoryRegistry` as well
as the :php:`ExtensionManagementUtility->makeCategorizable()`, which has required
creating a "TCA overrides" file.

While using the type :php:`category`, TYPO3 takes care of generating the
necessary TCA configuration.
Developers only have to define the TCA column and add :php:`category` as the
desired TCA type in the tables's TCA file (inside or outside of the Overrides folder).

.. include:: /CodeSnippets/Manual/CategorySimple.rst.txt
.. include:: /CodeSnippets/Manual/CategorySimple.rst.txt

The following options can be overridden via :ref:`page TSconfig, TCE form
<t3tsconfig:pageTsConfigTceFormConfig>`:

* `size`
* `maxitems`
* `minitems`
* `readOnly`
* `treeConfig`
* `size`
* `maxitems`
* `minitems`
* `readOnly`
* `treeConfig`

.. note::

.. note::
It is still possible to configure a category tree with `type=select`
and `renderType=selectTree` when you want to override specific fields,
but in most cases the simplified :php:`category` TCA type is sufficient.

It is still possible to configure a category tree with `type=select`
and `renderType=selectTree`. This configuration will still work, but
it can in most cases be simplified by using the new :php:`category` TCA type.

.. toctree::
:titlesonly:

.. toctree::
:titlesonly:

Examples
Properties/Index
Examples
Properties/Index
20 changes: 10 additions & 10 deletions Documentation/ColumnsConfig/Type/Category/Properties/Default.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.. include:: /Includes.rst.txt
.. _columns-category-properties-default:
.. include:: /Includes.rst.txt
.. _columns-category-properties-default:

=============
default value
=============

.. confval:: default
.. confval:: default
:name: category-default
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string
:Scope: Display / Proc.
:RenderType: all

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string
:Scope: Display / Proc.
:RenderType: all

Default value set if a new record is created. If empty, no category gets
selected.
Default value set if a new record is created. If empty, no category gets
selected.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
.. include:: /Includes.rst.txt
.. _columns-category-properties-exclusivekeys:
.. include:: /Includes.rst.txt
.. _columns-category-properties-exclusivekeys:

=============
exclusiveKeys
=============

.. confval:: exclusiveKeys
.. confval:: exclusiveKeys
:name: category-exclusiveKeys
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (list of)
:Scope: Display / Proc.
:RenderType: all

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (list of)
:Scope: Display / Proc.
:RenderType: all

List of keys that exclude any other keys in a select box where multiple
items could be selected. See also :ref:`property exclusiveKeys of selectTree
<columns-select-properties-exclusivekeys>`.
List of keys that exclude any other keys in a select box where multiple
items could be selected. See also :ref:`property exclusiveKeys of selectTree
<columns-select-properties-exclusivekeys>`.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
foreign\_table
==============

.. confval:: foreign_table (type => category)

.. confval:: foreign_table
:name: category-foreign-table
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (table name)
:Scope: Proc. / Display
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
foreign_table_prefix
====================

.. confval:: foreign_table_prefix (type => category)

.. confval:: foreign_table_prefix
:name: category-foreign-table-prefix
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string or LLL reference
:Scope: Display
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
foreign_table_where
===================

.. confval:: foreign_table_where (type => category)

.. confval:: foreign_table_where
:name: category-foreign-table-where
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (SQL WHERE)
:Scope: Proc. / Display
Expand Down
4 changes: 2 additions & 2 deletions Documentation/ColumnsConfig/Type/Category/Properties/Mm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ MM
referenced by TCA table columns. Dropping these definitions allows the Core
to adapt and migrate definitions if needed.

.. confval:: MM (type => category)

.. confval:: MM
:name: category-mm
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string (table name)
:Scope: Proc.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
.. include:: /Includes.rst.txt
.. _columns-category-properties-relationship:
.. include:: /Includes.rst.txt
.. _columns-category-properties-relationship:

============
relationship
============

.. confval:: relationship

:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string
:Scope: Display / Proc.
:RenderType: all
:Default: manyToMany

All possible values are:

`oneToOne`
Stores the uid of the selected category. When using this
relationship, `maxitems=1` will automatically be added to
the column configuration. While one record can only have a
relation to one category, each category can
still have a relationship to more then one record.

`oneToMany`
Stores the uids of selected categories in a comma-separated list.

`manyToMany` (default):
Uses the intermediate table :sql:`sys_category_record_mm`
and only stores the categories count on the local side. This is the use
case, which was previously accomplished using
:php:`ExtensionManagementUtility->makeCategorizable()`.

In the following example a category tree is displayed, but only one
category can be selected. It is

.. code-block:: php
$GLOBALS['TCA'][$myTable]['columns']['mainCategory'] = [
'config' => [
'type' => 'category',
'relationship' => 'oneToOne'
]
];
All other relevant options, for example `maxitems=1`, are being set
automatically.
.. confval:: relationship
:name: category-relationship
:Path: $GLOBALS['TCA'][$table]['columns'][$field]['config']
:type: string
:Scope: Display / Proc.
:RenderType: all
:Default: manyToMany

All possible values are:

`oneToOne`
Stores the uid of the selected category. When using this
relationship, `maxitems=1` will automatically be added to
the column configuration. While one record can only have a
relation to one category, each category can
still have a relationship to more then one record.

`oneToMany`
Stores the uids of selected categories in a comma-separated list.

`manyToMany` (default):
Uses the intermediate table :sql:`sys_category_record_mm`
and only stores the categories count on the local side. This is the use
case, which was previously accomplished using
:php:`ExtensionManagementUtility->makeCategorizable()`.

In the following example a category tree is displayed, but only one
category can be selected.

.. code-block:: php
$GLOBALS['TCA'][$myTable]['columns']['mainCategory'] = [
'config' => [
'type' => 'category',
'relationship' => 'oneToOne'
]
];
All other relevant options, for example `maxitems=1`, are being set
automatically.
Loading

0 comments on commit 76f2eba

Please sign in to comment.