#103502f:link.page pageUid and section together while in sub route
Description
Initial situation:
There are two routes for the same page. One is /page the other is /page/archive. The /page route is the base rout of the page. The /page/archive route is a additional route to call another controllerAction for the plugin set on that page. On both routes the page with the ID 5 is called. The plugin in the /page renders a button linking to /page/archive. In the route /page/archive the plugin renders a button to the /page route.
Setup:
Site config:
routeEnhancers:
MsEventKalender:
type: Extbase
extension: MsEvent
plugin: Kalender
dynamicPages:
withPlugin: msevent_kalender
routes:
-
routePath: '/archive/{year}'
_controller: 'Kalender::archiveAusstellungen'
_arguments:
year: year
-
routePath: /
_controller: 'Kalender::list'
defaults:
year: ''
aspects:
year:
type: StaticRangeMapper
start: '1944'
end: '2525'
Plugin used here: https://github.com/smichaelsen/typo3-dynamic-routing-pages but without its the same issue.
Plugin config:
ExtensionUtility::configurePlugin(
'MsEvent',
'Kalender',
[
\MediateSystems\MsEvent\Controller\KalenderController::class => 'list,listAusstellungen,listKunstprojekte,archiveAusstellungen',
],
// non-cacheable actions
[
\MediateSystems\MsEvent\Controller\KalenderController::class => 'list', //Removed for Testing Caching list,listAusstellungen,listKunstprojekte
],
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_PLUGIN
);
KalenderController.php list and archiveAction:
$this->view->assign("currentPageUid", $GLOBALS['TSFE']->id);
List.html action call:
<f:link.action action="archiveAusstellungen" controller="Kalender" title="{f:translate(key: 'tx_msevent_calender.gotoarchive')}" class="" pluginName="Kalender" addQueryString="false" extensionName="MsEvent" pageUid="{currentPageUid}">
<div class="filter-button-text"><f:translate key="tx_msevent_calender.gotoarchive"/></div>
</f:link.action>
This renders the URL www.baseurl.com/page/archive#eleID
ArchiveAustellungen.html page link call:
<f:link.page pageUid="{currentPageUid}" section="#kalenderentery" absolute="1">
<div class="filter-button-text"><f:translate key="tx_msevent_calender.exitarchive"/></div>
</f:link.page>
Like this it works but there happens the issue described below
Issue:
On the /page route the f:link.page works fine. If I am on the /page/archive route and use the <f:link pageuid="5">, it returns the URL “<a href="http://www.typo3page.com/page”" target="_blank" rel="noreferrer">www.typo3page.com/page”</a>, but if I use it combined with a section (<f:link pageuid="5" section="#eleID">) it returns the url “<a href="http://www.typo3page.com/page/archive#eleID”" target="_blank" rel="noreferrer">www.typo3page.com/page/archive#eleID”</a>. From My point of view the f:link.page should always return the base path of a page when a pageUid is set. In this case it doesn’t. The uriBuilder returns on call only “#eleID”. This happens because I am on the same page and it does not generate the base URL and compares it to the current URL. If I add the option absolute=“1” the f:link.page works fine because it will generate the base URL and return this URL with the section in addition.</f:link></f:link>
I hope this is understandable. If not a discussion on Slack was under https://typo3.slack.com/archives/C025BQLFA/p1711628411993009 and the base post was https://typo3.slack.com/archives/C025BQLFA/p1711622942688209.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 2
-
Georg Ringer commented and changed status
NewClosed <span data-processor="relativetime" data-value="2026-11-10T20:17:26+00:00" > 11/10/26, 20:17 </span>This has been fixed in
92273711620 #91761, main and 14.3).A typolink to a section of the current page was rendered as a bare
@#fragment@ as long as the link itself had no query parameters. The
shortcut is now only taken if the current request has no arguments
either. On a route enhanced sub route like/page/archive/2020the
link now correctly renders/page#fragment.I verified this with a functional test that uses a
Simpleroute
enhancer with/archive/{year}: without the change the link is
rendered as#c300, with the change as/welcome#c300.The issue was reported for v11, the fix has not been backported to
13.4 or older.If this is still valid for you in v14, please open a new issue and provide information how to reproduce it. Thanks!
Looks Like this is the reason: https://github.com/TYPO3/typo3/blob/cd89fcbd5f97717d07210ed4dc95d583445a6231/typo3/sysext/frontend/Classes/Typolink/PageLinkBuilder.php#L553-L561
A temporary workaround is to add a query string parameter. I’ve just used “type=0” which gets stripped aways anyways by default so the URL does not change but it’ll be generated with the path.