[BUGFIX] Re-enable target attribute for links in menus 92/60292/2
authorBenni Mack <benni@typo3.org>
Sun, 17 Mar 2019 11:10:09 +0000 (12:10 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 22 Mar 2019 20:42:33 +0000 (21:42 +0100)
The new pagelink builder does not set the lastTypoLinkLD options
which is used in HMENUs. The patch properly sets
the lastTypoLink* properties of ContentObjectRenderer in typolink
again, making target overrides in menus work again.

Resolves: #87130
Releases: master, 9.5
Change-Id: Ia284e546179dfaec8ec8ecb86a36d38f3b81aad8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60292
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php

index 677625b..497a0dc 100644 (file)
@@ -5019,6 +5019,9 @@ class ContentObjectRenderer implements LoggerAwareInterface
             );
             try {
                 list($this->lastTypoLinkUrl, $linkText, $target) = $linkBuilder->build($linkDetails, $linkText, $target, $conf);
+                $this->lastTypoLinkTarget = htmlspecialchars($target);
+                $this->lastTypoLinkLD['target'] = htmlspecialchars($target);
+                $this->lastTypoLinkLD['totalUrl'] = $this->lastTypoLinkUrl;
             } catch (UnableToLinkException $e) {
                 $this->logger->debug(sprintf('Unable to link "%s": %s', $e->getLinkText(), $e->getMessage()), ['exception' => $e]);
 
@@ -5027,6 +5030,9 @@ class ContentObjectRenderer implements LoggerAwareInterface
             }
         } elseif (isset($linkDetails['url'])) {
             $this->lastTypoLinkUrl = $linkDetails['url'];
+            $this->lastTypoLinkTarget = htmlspecialchars($target);
+            $this->lastTypoLinkLD['target'] = htmlspecialchars($target);
+            $this->lastTypoLinkLD['totalUrl'] = $this->lastTypoLinkUrl;
         } else {
             return $linkText;
         }
index 667eb45..e60abaa 100644 (file)
@@ -281,7 +281,6 @@ class PageLinkBuilder extends AbstractTypolinkBuilder
             );
             $url = $this->contentObjectRenderer->getTypoLink_URL($thePage['uid'] . ($pageType ? ',' . $pageType : ''), $addParams, $target);
             $url = $this->forceAbsoluteUrl($url, $conf);
-            $this->contentObjectRenderer->lastTypoLinkLD['totalUrl'] = $url;
         }
 
         // Setting title if blank value to link