Typo3 8.7从TCA覆盖页面返回GLOBAL be_user值

时间:2020-08-13 11:08:13

标签: typo3-8.x typo3-extensions

我创建了一个新的后端变量,称为“ userval”。 我可以在任何控制器中通过简单的调用来引用该值:

$GLOBALS['BE_USER']->user['userval']

但是,我需要通过TCA / Overrides / tt_content.php页面从另一个扩展中获取此值。上面的代码在这里不起作用(我收到一个空值)。是否可以从tt_content.php访问BE_USER值?

1 个答案:

答案 0 :(得分:0)

更新-我没有设法弄清楚,但是我找到了一个更好的解决方案,可能对其他人有用。

我需要此信息,因为我想从链接到“ userval”字段的表中返回项目列表。但是下面的示例已简化为更通用。.

我发现tt_content.php可以通过控制器将数据直接传递给它。在tt_content.php文件中,添加以下内容:

Dim myChart As Graph.Chart
Dim myChartSeries As Graph.Series
Dim mySeriesDataLabel As Graph.DataLabel

Set myChart = Me.myGraph.Object

For Each myChartSeries In myChart.SeriesCollection

For Each mySeriesDataLabel In myChartSeries.DataLabels
mySeriesDataLabel.Font.Name = "Times New Roman"
    mySeriesDataLabel.Font.FontStyle = "Normal"
mySeriesDataLabel.Font.Size = 8
Next mySeriesDataLabel
Next myChartSeries

With Me.myGraph.Axes(1).TickLabels.Font
    .Name = "Times New Romans"
    .FontStyle = "Normal"
    .Size = 8
End With

With Me.myGraph.Axes(2).TickLabels.Font
    .Name = "Times New Romans"
    .FontStyle = "Normal"
    .Size = 8
End With

),

...请注意“ itemsProcFunc”行。这引用了ExampleController返回的数据。

在ExampleController中,这是将数据发送到tt_content.php中的方法:

'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',
相关问题