-
-
Save jmverges/9893fd6ee85c069c9687 to your computer and use it in GitHub Desktop.
Showing the preview section of fluidpages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/db_layout.php']['drawHeaderHook'][] = \My\Extension\Hooks\PagePreviewRenderer::class . '->render'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My\Extension\Hooks; | |
use FluidTYPO3\Fluidpages\Provider\PageProvider; | |
use TYPO3\CMS\Backend\Controller\PageLayoutController; | |
use TYPO3\CMS\Core\Utility\GeneralUtility; | |
use TYPO3\CMS\Extbase\Object\ObjectManager; | |
use FluidTYPO3\Flux\Service\WorkspacesAwareRecordService; | |
use FluidTYPO3\Flux\View\PreviewView; | |
class PagePreviewRenderer { | |
/** | |
* @param array $params | |
* @param PageLayoutController $pageLayoutController | |
* @return string | |
*/ | |
public function render(array $params, PageLayoutController $pageLayoutController) { | |
/** @var ObjectManager $objectManager */ | |
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); | |
/** @var WorkspacesAwareRecordService $recordService */ | |
$recordService = $objectManager->get(WorkspacesAwareRecordService::class); | |
/** @var PageProvider $pageProvider */ | |
$pageProvider = $objectManager->get(PageProvider::class); | |
$row = $recordService->getSingle('pages', '*', $pageLayoutController->id); | |
$form = $pageProvider->getForm($row); | |
#prevent rendering of the grid twice | |
$form->setOption(PreviewView::OPTION_PREVIEW, array( | |
PreviewView::OPTION_MODE => PreviewView::MODE_NONE | |
)); | |
list($previewHeader, $previewContent, $continueDrawing) = $pageProvider->getPreview($row); | |
return $previewContent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment