[BUGFIX] Set anchor in all preview links of content elements 91/53691/2
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:38:23 +0000 (11:38 +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/53691
Tested-by: TYPO3com <no-reply@typo3.com>
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 f19352e..f9dd6f2 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 b28b92b..35e1b4a 100644 (file)
@@ -872,6 +872,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);
 
@@ -883,7 +886,7 @@ class EditDocumentController extends AbstractModule
                 $this->popViewId,
                 '',
                 $previewPageRootline,
-                '',
+                $anchorSection,
                 $this->viewUrl,
                 $this->popViewId_addParams,
                 false
@@ -895,7 +898,7 @@ class EditDocumentController extends AbstractModule
                 $this->popViewId,
                 '',
                 $previewPageRootline,
-                '',
+                $anchorSection,
                 $this->viewUrl,
                 $this->popViewId_addParams
             )