From 08dbe27087b783c3b5e34b4b34cf4b88f1f09106 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Sun, 11 Jan 2026 14:14:04 +0100 Subject: [PATCH] =?UTF-8?q?[BUGFIX]=C2=A0Fix=20backend=20previews=20in=20v?= =?UTF-8?q?14?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a problem for previous versions with the partial --- Classes/Backend/Preview/ContentPreview.php | 4 ++++ Classes/Service/DatabaseRowService.php | 28 ++++++++++++++++++++++ Resources/Private/Partials/Link.html | 4 ++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Classes/Backend/Preview/ContentPreview.php b/Classes/Backend/Preview/ContentPreview.php index 524c577..8bbddf7 100644 --- a/Classes/Backend/Preview/ContentPreview.php +++ b/Classes/Backend/Preview/ContentPreview.php @@ -12,6 +12,7 @@ * of the License, or any later version. */ +use B13\Backendpreviews\Service\DatabaseRowService; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\PageLayoutContext; use TYPO3\CMS\Core\Domain\RecordInterface; @@ -54,6 +55,9 @@ public function render(RecordInterface $record, PageLayoutContext $context): ?st $context->getCurrentRequest() ) ); + + $data = GeneralUtility::makeInstance(DatabaseRowService::class)->getAdditionalDataForView($record); + $view->assignMultiple($data); $view->assign('record', $record); try { return $view->render($fluidTemplateName); diff --git a/Classes/Service/DatabaseRowService.php b/Classes/Service/DatabaseRowService.php index 2a7a7ac..e6af81d 100644 --- a/Classes/Service/DatabaseRowService.php +++ b/Classes/Service/DatabaseRowService.php @@ -15,6 +15,7 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Domain\RecordInterface; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Resource\FileReference; use TYPO3\CMS\Core\Resource\FileRepository; @@ -31,6 +32,33 @@ public function __construct(FileRepository $fileRepository) $this->fileRepository = $fileRepository; } + public function getAdditionalDataForView(RecordInterface $record): array + { + $data = []; + if ($this->getBackendUser()->recordEditAccessInternals($record->getMainType(), $record)) { + $urlParameters = [ + 'edit' => [ + 'tt_content' => [ + $record->getUid() => 'edit', + ], + ], + 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') . '#element-tt_content-' . $record->getUid(), + ]; + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + $url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters); + $return = [ + 'url' => $url, + 'title' => htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_layout.xlf:edit')), + ]; + $data['editLink'] = $return; + } + + $data['CType-label'] = $this->getLanguageService()->sL( + BackendUtility::getLabelFromItemListMerged($record->getPid(), 'tt_content', 'CType', $record->get('CType')) + ); + return $data; + } + public function extendRow(array $row): array { if ($this->getBackendUser()->recordEditAccessInternals('tt_content', $row)) { diff --git a/Resources/Private/Partials/Link.html b/Resources/Private/Partials/Link.html index 699a5c1..8a0c2b2 100644 --- a/Resources/Private/Partials/Link.html +++ b/Resources/Private/Partials/Link.html @@ -3,10 +3,10 @@ data-namespace-typo3-fluid="true" > - +