‪TYPO3CMS  9.5
RenderContentElementPreviewViewHelper.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
21 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
23 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
24 
32 class ‪RenderContentElementPreviewViewHelper extends AbstractViewHelper
33 {
34  use CompileWithRenderStatic;
35 
41  protected ‪$escapeOutput = false;
42 
48  public function ‪initializeArguments()
49  {
50  $this->registerArgument('contentElementUid', 'int', 'The uid of a content element');
51  }
52 
60  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
61  {
62  $content = '';
63  $contentElementUid = $arguments['contentElementUid'];
64  $contentRecord = ‪BackendUtility::getRecord('tt_content', $contentElementUid);
65  if (!empty($contentRecord)) {
66  $pageLayoutView = GeneralUtility::makeInstance(PageLayoutView::class);
67  $content = $pageLayoutView->tt_content_drawItem($contentRecord);
68  }
69  return $content;
70  }
71 }
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: RenderContentElementPreviewViewHelper.php:58
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: RenderContentElementPreviewViewHelper.php:39
‪TYPO3\CMS\Form\ViewHelpers\Be
Definition: RenderContentElementPreviewViewHelper.php:3
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper\initializeArguments
‪initializeArguments()
Definition: RenderContentElementPreviewViewHelper.php:46
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper
Definition: RenderContentElementPreviewViewHelper.php:33
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:130
‪TYPO3\CMS\Backend\View\PageLayoutView
Definition: PageLayoutView.php:61
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45