label_userFunc

label_userFunc
Type:string
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]->[methodname]. The passed argument is an array which contains the following information about the record for which to get the title:

$params['table'] = $table;
$params['row'] = $row;

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:examples/Configuration/TCA/tx_examples_haiku.php file:

'ctrl' => [
   'label' => 'title',
   'label_userFunc' => \Documentation\Examples\Userfuncs\Tca::class . '->haikuTitle',
],

Class Documentation\Examples\Userfuncs\Tca 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:string
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_userFunc is used for inline (IRRE) elements, the options are not passed. If you need options use formattedLabel_userFunc instead.