Project

General

Profile

Actions

Bug #103502

open

f:link.page pageUid and section together while in sub route

Added by Stefan Bicha 8 months ago. Updated 7 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2024-03-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

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.page pageUid="5">, it returns the URL "www.typo3page.com/page", but if I use it combined with a section (<f:link.page pageUid="5" section="#eleID">) it returns the url "www.typo3page.com/page/archive#eleID". 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.

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.

Actions #1

Updated by Sascha Egerer 7 months ago · Edited

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.

Actions

Also available in: Atom PDF