Eine neue Klasse in der eigenen Extension
In meinem Fall liegt die Klasse in typo3conf/ext/gallery/classes/class.page_layoutView
Meine Extension heißt tx_gallery und soll als Vorschau eine Liste der Thumbnails meiner Galerie anzeigen.
Die Klasse muss das Interface \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface implementieren und benötigt zwingend eine Methode
preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row)
Da in meiner Extension Bilder über den TYPO3 FAL (File Abstraction Layer) hinzugefügt werden, kann ich hier ganz einfach Thumbnails über die Methode thumbCode ausgeben assen.
<?php
class tx_gallery_tt_content_drawItem implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
/**
* Preprocesses the preview rendering of a content element.
*
* @param tx_cms_layout $parentObject: Calling parent object
* @param boolean $drawItem: Whether to draw the item using the default functionalities
* @param string $headerContent: Header content
* @param string $itemContent: Item content
* @param array $row: Record row of tt_content
* @return void
*/
public function preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row) {
switch($row['list_type']) {
case 'gallery_pi1':
$drawItem = FALSE;
$headerContent = '<b>Bildergalerie' . $headerContent."</b><br><br>";
$itemContent=$parentObject->thumbCode($row, 'tt_content', 'image') . '<br />';
break;
}
}
}
?>Achtung, diese Implemetierung gilt erst ab TYPO3 Version 6.0.
Eine Implementierung für frühere TYPO3-Versionen würde folgendermaßen aussehen:
class tx_t3_default_resources_txCmsLayoutDrawItemHook implements tx_cms_layout_tt_content_drawItemHook {
public function preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row){
}
}Hallo TYPO3 - Hallo Klasse
Um die Klasse in TYPO3 noch bekannt zu machen, muss diese in der ext_localconf.php registriert werden. Das funktioniert folgendermaßen:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$_EXTKEY] = t3lib_extMgm::extPath($_EXTKEY).'classes/class.page_layoutView.php:tx_gallery_tt_content_drawItem';

