如何正确使用tt_news中的钩子,每次添加

I recently tried to use Generic Markers to put out some Database content via TypoScript, but I need to be more flexible, so I'm looking for a solution to make use of hooks to tt_news. I want to parse my own Template of data into the MarkerArray of tt_news.

My own extension comes with /Classes/Controller/FahrzeugController.php and I added the function extraItemMarkerProcessor(..), according to the codehook provided by tt_news.

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

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

Then I added some Config-Parameters in my 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

The template part works, as I tested it with generic Markers and the same file. According to many internet guides, it should work out of the box like this. But I don't see anything in any view.

I don't even know, where to start looking.

Your Hook registration in your ext_localconf is wrong. tx_y7fahrzeugdatenbank does not belong there. You have to tell tt_news in which php class your code is found. That would be Vendor\Extension\Controller\FahrzeugController if you followed the extbase Folder structure your class shoukd be autoloaded.

But I strongly suggest not to use an extbase controller for a tt_news Hook. Use a class that only contains your code that should be executed by the hook and nothing more. Put in In your_extenion/Classes/Hooks. Use a proper namespace and TYPO3 will autoload your class for you.

In your ext_localconf.php it will be

$TYPO3_CONF_VARS['EXTCONF']['tt_news']['extraItemMarkerHook'][] = 'Vendor\Extension\Hooks\ClassContainingMyHook';