0

我最近尝试使用通用标记通过 TypoScript 输出一些数据库内容,但我需要更加灵活,所以我正在寻找一种解决方案来利用 tt_news 的钩子。我想将我自己的数据模板解析为 tt_news 的 MarkerArray。

根据tt_news提供的codehook,我自己的扩展是/Classes/Controller/FahrzeugController.php,我添加了函数extraItemMarkerProcessor(..)。

<?
class FahrzeugController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
function extraItemMarkerProcessor($markerArray, $row, $lConf, $obj) {

$markerArray['###FAHRZEUGE###'] = 'exItMaPro';
return $markerArray;
}
}?>

然后我在 ext_localconf.php 中添加了一些配置参数。

if (TYPO3_MODE!='BE')   {
require_once(t3lib_extMgm::extPath('y7_fahrzeugdatenbank').'/Classes/Controller/FahrzeugController.php');
}
// y7_fahrzeugdatenbank = Path to my Extension , followed by relative path to my .php .

$TYPO3_CONF_VARS['EXTCONF']['tt_news']['extraItemMarkerHook'][] = 'EXT:y7_fahrzeugdatenbank/Classes/Controller/FahrzeugController.php:tx_y7fahrzeugdatenbank'; // tx_y7fahrzeugdatenbank is my SQL prefix

模板部分有效,因为我使用通用标记和相同的文件对其进行了测试。根据许多互联网指南,它应该像这样开箱即用。但我从任何角度都看不到任何东西。

我什至不知道,从哪里开始寻找。

4

1 回答 1

0

您在 ext_localconf 中的 Hook 注册是错误的。tx_y7fahrzeugdatenbank不属于那里。您必须告诉 tt_news 您的代码是在哪个 php 类中找到的。那就是Vendor\Extension\Controller\FahrzeugController如果你遵循 extbase 文件夹结构,你的类应该被自动加载。

但我强烈建议不要将 extbase 控制器用于 tt_news Hook。使用一个只包含应该由钩子执行的代码的类,仅此而已。放入 your_extenion/Classes/Hooks 中。使用适当的命名空间,TYPO3 将为您自动加载您的课程。

在你的ext_localconf.php它将是

$TYPO3_CONF_VARS['EXTCONF']['tt_news']['extraItemMarkerHook'][] = 'Vendor\Extension\Hooks\ClassContainingMyHook';
于 2015-03-16T21:24:17.833 回答