[BUGFIX] Set anchor in all preview links of content elements 95/53395/4
authorDan Untenzu <mail@pixelbrackets.de>
Tue, 4 Jul 2017 12:06:03 +0000 (14:06 +0200)
committerSusanne Moog <susanne.moog@typo3.org>
Mon, 14 Aug 2017 09:20:46 +0000 (11:20 +0200)
The button »View webpage« in the list module opens a popup
with a link to the current page and an anchor to the
selected content element. This behaviour is expected as well
while selecting the »Show« option in the context menu of
content elements or the »Save and view page« button in
edit forms. Both places didn't added the anchor.

Resolves: #81250
Releases: master, 8.7
Change-Id: Ifa8da940eb12820f9b0c54957928fd8d9f3703b5
Reviewed-on: https://review.typo3.org/53395
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Tested-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
typo3/sysext/backend/Classes/ContextMenu/ItemProviders/RecordProvider.php
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index b7633b0..ec401c8 100644 (file)
@@ -416,7 +416,13 @@ class RecordProvider extends AbstractProvider
      */
     protected function getViewLink(): string
     {
-        $javascriptLink = BackendUtility::viewOnClick($this->getPreviewPid());
+        $anchorSection = $this->table === 'tt_content' ? '#c' . $this->record['uid'] : '';
+        $javascriptLink = BackendUtility::viewOnClick(
+            $this->getPreviewPid(),
+            '',
+            null,
+            $anchorSection
+        );
         $extractedLink = '';
         if (preg_match('/window\\.open\\(\'([^\']+)\'/i', $javascriptLink, $match)) {
             // Clean JSON-serialized ampersands ('&')
index b6daa5e..0fef121 100644 (file)
@@ -866,6 +866,9 @@ class EditDocumentController extends AbstractModule
             $linkParameters = array_replace($linkParameters, $additionalGetParameters);
         }
 
+        // anchor with uid of content element]
+        $anchorSection = $table === 'tt_content' ? '#c' . $recordId : '';
+
         $this->popViewId = $previewPageId;
         $this->popViewId_addParams = GeneralUtility::implodeArrayForUrl('', $linkParameters, '', false, true);
 
@@ -877,7 +880,7 @@ class EditDocumentController extends AbstractModule
                 $this->popViewId,
                 '',
                 $previewPageRootline,
-                '',
+                $anchorSection,
                 $this->viewUrl,
                 $this->popViewId_addParams,
                 false
@@ -889,7 +892,7 @@ class EditDocumentController extends AbstractModule
                 $this->popViewId,
                 '',
                 $previewPageRootline,
-                '',
+                $anchorSection,
                 $this->viewUrl,
                 $this->popViewId_addParams
             )