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 v10 here: TYPO3 ELTS.
generatorOptions
generatorOptions
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Proc. / Display
Holds information about the record fields to be used for slug generation:
generatorOptions:fields
-
- type
-
array
- Scope
-
Proc. / Display
Insert several field names (of type string) that will be considered during slug construction.
Can also be used as nested array to combine multiple fields
[
.['nav_ title', 'title'], 'other_ field'] Info
Inserting multiple fields in a simple array would result in an concatenated slug.
Nested array values would result in "take
nav_
if not empty, otherwise take value fromtitle title
".Examples:
Configuration value Values of an example page record Resulting slug [
['nav_ title', 'title']] ['title' => 'Products', 'nav_
title' => ''] /products
[
['title', 'subtitle']] ['title' => 'Products', 'subtitle' => 'Product subtitle']
/products
['title', 'subtitle']
or[
['title'], ['subtitle']] ['title' => 'Products', 'subtitle' => 'Product subtitle']
/products/
product- subtitle ['nav_
title', 'title'], 'subtitle' ['title' => 'Products', 'nav_
title' => 'Best products', 'subtitle' => 'Product subtitle'] /best-
products/ product- subtitle ['seo_
title', 'title'], ['nav_ title', 'subtitle'] ['title' => 'Products', 'nav_
title' => 'Best products', 'subtitle' => 'Product subtitle', 'seo_ title' => 'SEO product title'] /seo-
product- title/ best- products
generatorOptions:fieldSeparator
-
- name
-
slug-generatorOptions-fieldSeparator
- type
-
string
- Scope
-
Proc. / Display
- Default
-
"/"
This value will divide the slug parts. If a section value contains this very value, it will be replaced by the value given in fallbackCharacter.
generatorOptions:prefixParentPageSlug
-
- name
-
slug-generatorOptions-prefixParentPageSlug
- type
-
boolean
- Default
-
true
- Scope
-
Proc. / Display
The slugs of parent pages will be prefixed to the slug for the page itself. Disable it for shorter URLs, but take the higher chance of collision into consideration.
Note
This option is exclusively for page records. It won't have an effect on any other records.
generatorOptions:replacements
-
- name
-
slug-generatorOptions-replacements
- type
-
array
- Scope
-
Proc. / Display
It allows to replace strings of a slug part. Add one of more array items with the key being the string to replace and the value being the replacement string.
generatorOptions:postModifiers
-
- name
-
slug-generatorOptions-postModifiers
- type
-
array
- Scope
-
Proc. / Display
The "slug" TCA type includes a possibility to hook into the generation of a slug via custom TCA generation options.
Hooks can be registered via:
$GLOBALS['TCA'][$tableName]['columns'][$fieldName]['config']['generatorOptions']['postModifiers'][] = MyClass::class . '->method';
Copied!Consider
$table
andName = 'pages' $field
insideName = 'slug' EXT:
:my_ extension/ Configuration/ TCA/ Overrides/ table. php $GLOBALS['TCA']['pages']['columns']['slug']['config']['generatorOptions']['postModifiers'][] = MyClass::class . '->modifySlug';
Copied!The method then receives an parameter array with the following values
[ 'slug', // ... the slug to be used 'workspaceId', // ... the workspace ID, "0" if in live workspace 'configuration', // ... the configuration of the TCA field 'record', // ... the full record to be used 'pid', // ... the resolved parent page ID 'prefix', // ... the prefix that was added 'tableName', // ... the table of the slug field 'fieldName', // ... the field name of the slug field ];
Copied!All hooks need to return the modified slug value.
Examples
Generate a concatenated slug
[
'columns' => [
'slug_4' => [
'exclude' => 1,
'label' => 'slug_4',
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => [
'input_1',
'input_2',
],
'prefixParentPageSlug' => false,
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInSite',
'default' => '',
],
],
],
]
Generate a slug from one field with a backup field if first is empty
[
'columns' => [
'slug_5' => [
'exclude' => 1,
'label' => 'slug_5',
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => [
[
'input_1',
'input_2',
],
],
'prefixParentPageSlug' => false,
],
'fallbackCharacter' => '-',
'eval' => 'uniqueInSite',
'default' => '',
],
],
],
]
Example: remove all strings "(f/m)" from Jobtitles
This will change the provided slug 'Some Job in city1/city2 (f/m)' to 'some-job-in-city1-city2'.
[
'columns' => [
'slug_3' => [
'exclude' => 1,
'label' => 'slug_3',
'description' => 'remove string (f/m)',
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => [
'input_3',
],
'replacements' => [
'(f/m)' => '',
'/' => '-',
],
],
'fallbackCharacter' => '-',
'prependSlash' => true,
'eval' => 'uniqueInPid',
],
],
],
]