‪TYPO3CMS  10.4
RenderContentElementPreviewViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
23 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
25 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
26 
34 class ‪RenderContentElementPreviewViewHelper extends AbstractViewHelper
35 {
36  use CompileWithRenderStatic;
37 
43  protected ‪$escapeOutput = false;
44 
50  public function ‪initializeArguments()
51  {
52  $this->registerArgument('contentElementUid', 'int', 'The uid of a content element');
53  }
54 
62  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
63  {
64  $content = '';
65  $contentElementUid = $arguments['contentElementUid'];
66  $contentRecord = ‪BackendUtility::getRecord('tt_content', $contentElementUid);
67  if (!empty($contentRecord)) {
68  $pageLayoutView = GeneralUtility::makeInstance(PageLayoutView::class);
69  $content = $pageLayoutView->tt_content_drawItem($contentRecord);
70  }
71  return $content;
72  }
73 }
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: RenderContentElementPreviewViewHelper.php:60
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper\$escapeOutput
‪bool $escapeOutput
Definition: RenderContentElementPreviewViewHelper.php:41
‪TYPO3\CMS\Form\ViewHelpers\Be
Definition: MaximumFileSizeViewHelper.php:18
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper\initializeArguments
‪initializeArguments()
Definition: RenderContentElementPreviewViewHelper.php:48
‪TYPO3\CMS\Form\ViewHelpers\Be\RenderContentElementPreviewViewHelper
Definition: RenderContentElementPreviewViewHelper.php:35
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:75
‪TYPO3\CMS\Backend\Utility\BackendUtility\getRecord
‪static array null getRecord($table, $uid, $fields=' *', $where='', $useDeleteClause=true)
Definition: BackendUtility.php:95
‪TYPO3\CMS\Backend\View\PageLayoutView
Definition: PageLayoutView.php:61
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46