Skip to content

Instantly share code, notes, and snippets.

@stafast
Created June 15, 2016 07:41
Show Gist options
  • Save stafast/e3c3ede3af20b92cf6863beba9fa6eac to your computer and use it in GitHub Desktop.
Save stafast/e3c3ede3af20b92cf6863beba9fa6eac to your computer and use it in GitHub Desktop.
Preview Rrenderer for IRRE with FAL
<?php
namespace Slider\Slider\Hooks;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\PageLayoutView;
use TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Contains a preview rendering for the page module of CType="slider"
*/
class SliderRenderer implements PageLayoutViewDrawItemHookInterface
{
/**
* Preprocesses the preview rendering of a content element of type "slider"
*
* @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object
* @param bool $drawItem Whether to draw the item using the default functionality
* @param string $headerContent Header content
* @param string $itemContent Item content
* @param array $row Record row of tt_content
*
* @return void
*/
public function preProcess(
PageLayoutView &$parentObject,
&$drawItem,
&$headerContent,
&$itemContent,
array &$row
)
{
if ($row['CType'] === 'slider') {
$itemContent .= '<strong>' . $parentObject->linkEditContent('Slider', $row) . '</strong>';
$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$itemRepository = $objectManager->get('Slider\Slider\Domain\Repository\ItemRepository');
foreach ($itemRepository->findByTtContentUid($row['uid']) as $item) {
$itemContent .= '<p>';
$itemContent .= '' . $parentObject->linkEditContent($parentObject->renderText($item->getHeader()), $row) . '<br/>';
$itemContent .= BackendUtility::thumbCode(
array(
'uid' => $item->getUid(),
'image' => $item->getImage()
), 'tx_slider_domain_model_item', 'image', $backPath = '', $thumbScript = '', $uploaddir = null, $abs = 0, $tparams = '', $size = '128x64'
);
$itemContent .= BackendUtility::thumbCode(
array(
'uid' => $item->getUid(),
'image_small' => $item->getImage()
), 'tx_slider_domain_model_item', 'image_small', $backPath = '', $thumbScript = '', $uploaddir = null, $abs = 0, $tparams = '', $size = '96x64'
);
$itemContent .= '</p>';
}
$headerContent = '';
$drawItem = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment