From a980f79c69b7daf8c703335d83bb59627da84574 Mon Sep 17 00:00:00 2001 From: Michael Krohn Date: Sun, 12 Nov 2023 19:49:34 +0100 Subject: [PATCH] [BUGFIX] Get correct page id for a shortcut --- Classes/Event/Listener/AfterLinkIsGeneratedListener.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Classes/Event/Listener/AfterLinkIsGeneratedListener.php b/Classes/Event/Listener/AfterLinkIsGeneratedListener.php index 4e1a8150..f7695622 100644 --- a/Classes/Event/Listener/AfterLinkIsGeneratedListener.php +++ b/Classes/Event/Listener/AfterLinkIsGeneratedListener.php @@ -12,6 +12,7 @@ namespace FriendsOfTYPO3\Headless\Event\Listener; use FriendsOfTYPO3\Headless\Utility\HeadlessFrontendUrlInterface; +use TYPO3\CMS\Core\Domain\Repository\PageRepository; use TYPO3\CMS\Core\LinkHandling\LinkService; use TYPO3\CMS\Core\Site\Entity\NullSite; use TYPO3\CMS\Frontend\Event\AfterLinkIsGeneratedEvent; @@ -31,7 +32,12 @@ public function __invoke(AfterLinkIsGeneratedEvent $event): void return; } - $pageId = $result->getLinkConfiguration()['parameter'] ?? 0; + $page = $result->getLinkConfiguration()['page'] ?? null; + if ($page != null && $page['doktype'] == PageRepository::DOKTYPE_SHORTCUT) { + $pageId = $page['shortcut']; + } else { + $pageId = $result->getLinkConfiguration()['parameter'] ?? 0; + } if (isset($result->getLinkConfiguration()['parameter.'])) { $pageId = (int)($this->linkService->resolve($event->getContentObjectRenderer()->parameters['href'] ?? '')['pageuid'] ?? 0);