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.
label_userFunc
label_userFunc
-
- Type
- string
- Path
- $GLOBALS['TCA'][$table]['ctrl']
- Scope
- Display
Function or method reference. This can be used whenever the label or label_alt options don't offer enough flexibility, e.g. when you want to look up another table to create your label. The result of this function overrules the label, label_alt and label_alt_force settings.
When calling a method from a class, enter
[classname]->
. The passed argument is an array which contains the following information about the record for which to get the title:[methodname] $params['table'] = $table; $params['row'] = $row;
Copied!The resulting title must be written to $params['title'], which is passed by reference.
Warning
The title is passed later on through
htmlspecialchars
so it may not include any HTML formatting.()
Example
Let's look at what is done for the "haiku" table of the "examples" extension. The call to the user function appears
in the EXT:
file:
'ctrl' => [
'label' => 'title',
'label_userFunc' => \Documentation\Examples\Userfuncs\Tca::class . '->haikuTitle',
],
Class Documentation\
contains the code itself:
public function haikuTitle(&$parameters)
{
$record = BackendUtility::getRecord($parameters['table'], $parameters['row']['uid']);
$newTitle = $record['title'];
$newTitle .= ' (' . substr(strip_tags($record['poem']), 0, 10) . '...)';
$parameters['title'] = $newTitle;
}
label_userFunc_options
label_userFunc_options
-
- type
-
array
- Scope
-
Display
Options for label_userFunc. The array of options is passed to the user function in the parameters array with key "options".
Note
When the
label_
is used for inline (IRRE) elements, the options are not passed. If you need options use formattedLabel_userFunc instead.user Func