Skip to content

Commit

Permalink
[BUGFIX] Get correct page id for a shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
KrohnMi committed Nov 12, 2023
1 parent bd22170 commit a980f79
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Classes/Event/Listener/AfterLinkIsGeneratedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit a980f79

Please sign in to comment.