Feature: #88198 - TCA-based Slug modifiers for extensions
See forge#88198
Description
The new "slug" TCA type now 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'][] = My\Class::class . '->method';
Copied!
in EXT:
, where $tableName can be a table like pages
and
$field
matches the slug field name, e.g. slug
.
Example:
$GLOBALS['TCA']['pages']['columns']['slug']['config']['generatorOptions']['postModifiers'][] = My\Class::class . '->modifySlug';
Copied!
The method then receives a 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' ... important fields of the record (available fields might differ from usage type)
'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.
Impact
Any extension can modify a specific slug, for instance only for a specific part of the page tree.
It is also possible for extensions to implement custom functionality like "Do not include in slug generation" as known from RealURL.