label_userFunc

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]->[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;
Copied!

The resulting title must be written to $params['title'], which is passed by reference.

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',
],
Copied!

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;
}

Copied!

label_userFunc_options

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".