#101388Add possibility to modify "canonical" tag even from within uncached extbase controller action
Description
Currently it is not possible to manually modify the “canonical” tag from within an uncached extbase controller action. Canonical can only be modified when action is cached by setting “$GLOBALS[‘TSFE’]->page[‘canonical_link’]”. The only possibility to modify the tag even when in an uncached context is to use the “ModifyUrlForCanonicalTagEvent” (EXT:seo) like this:
class FilterSeminarEventsCanonicalEventListener
{
public function __invoke(ModifyUrlForCanonicalTagEvent $event): void
{
if($params = $this->getServerRequest()->getQueryParams()['tx_myext_seminar']) {
if($params['action'] == 'filterSeminarEvents') {
$seminarUid = (int) $params['seminar'];
$locationUid = (int) $params['location'];
$eventUid = (int) $params['event'];
if($seminarUid > 0 && ($locationUid > 0 || $eventUid > 0)) {
/** @var Site $site */
$site = $this->getServerRequest()->getAttribute('site');
$parameters = [
'tx_myext_seminar' => [
'action' => 'show',
'controller' => 'Seminars\Seminar',
'seminar' => $seminarUid
]
];
$url = (string) $site->getRouter()->generateUri($this->getTypoScriptFrontendController()->id, $parameters);
$event->setUrl($url);
}
}
}
}
/**
* Returns the typoScriptFrontendController
*
* @return TypoScriptFrontendController
*/
private function getTypoScriptFrontendController()
{
return $GLOBALS['TSFE'];
}
/**
* Returns serverRequest
*
* @return ServerRequest
*/
private function getServerRequest()
{
return $GLOBALS['TYPO3_REQUEST'];
}
}
But in addition, there should be an alternate and easier way to modify the canonical directly from e.g. a controller action. Perhaps any implementation similar to PageTitle API or MetaTag API could be added.
Reviews 1
Related issues 1
History 34
-
Chris Müller changed tracker
BugFeature TYPO3 Version10<span data-processor="relativetime" data-value="2023-07-19T18:14:05+00:00" > 07/19/23, 18:14 </span> -
Jan Kornblum changed Related to #106168 <span data-processor="relativetime" data-value="2025-02-13T11:07:07+00:00" > 02/13/25, 11:07 </span>
-
Gerrit Code Review pushed patch set 1 for main to change 97813 status
NewUnder Review <span data-processor="relativetime" data-value="2026-11-19T07:48:49+00:00" > 11/19/26, 07:48 </span> -
Benni Mack commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-11-20T16:25:12+00:00" > 11/20/26, 16:25 </span>
Applied in changeset commit:eaf1c6217901d02496575c3cb3fa6e840aced901.