I have created a new back-end variable called "userval". I can reference this value in any controller by simply calling:
$GLOBALS['BE_USER']->user['userval']
However I need to get this value from another extensions, via the TCA/Overrides/tt_content.php page. The above code doesn't work here (I receive an empty value). Is it possible to access the BE_USER values from tt_content.php?
Update - I didn't manage to figure it out but I found a better solution that might work for others.
I needed this information because I wanted to return a list of items from a table that was linked to the field "userval". But the example below has been simplified for more general use..
I discovered that tt_content.php can have data passed directly to it via a controller. In the tt_content.php file, add the following:
'tx_some_example' =>
array(
'config' =>
array(
'type' => 'select',
'renderType' => 'selectSingle',
'items' => array (),
'itemsProcFunc' => 'SomeDomain\SomeExtensionName\Controller\ExampleController->getItems',
'selicon_cols' => 8,
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
),
'exclude' => '1',
'label' => 'Some example',
),
...note the "itemsProcFunc" line. This references returned data from the ExampleController.
In the ExampleController, here's how you can send the data into tt_content.php:
public function getItems($config){
//Sample data - this could be a DB call, a list in a folder, or a simple array like this
$sampleArray[
"id1" => "ID 1 Label",
"id2" => "ID 2 Label",
"id3" => "ID 3 Label",
];
$optionList = [];
$count=0;
//Cycle through each item, and add it to the desired dropdown list
foreach ($sampleArray as $id => $label) {
$optionList[$count] = [0 => $label, 1 => $id];
$count++;
}
//Pass the data back to the tt_content.php page
$config['items'] = array_merge($config['items'], $optionList);
return $config;
}