Project

General

Profile

Actions

Bug #91517

closed

Section-Link pointing the current page not rendering without config.baseURL

Added by Philipp Seiler almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2020-05-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.2
Tags:
section,hash,baseurl,site,configuration,variant,base
Complexity:
Is Regression:
Sprint Focus:

Description

  • Have a typolink, e.g. created in a textmedia-element, that points to the same site to a different content element. The typolink should look something like <a href="t3://page?uid=123#456">Link to content element on the current page</a>, where 123 is the current site.
  • The base-tag on the site gets set via page.headerData in order to dynamically get BaseVariants from the SiteConfiguration. Works nicely without needing additional conditions or configurations. The TypoScript setting config.baseURL is not used.
  • Link will be rendered incorrectly in the frontend. It will point to the root-URL of the current SiteConfiguration without the current path segment. E.g. if the page would be located under my/path/segment/ and the dynamically set base-URL is https://www.mypage.com, the link should be https://www.mypage.com/my/path/segment#456, it is rendered however like https://www.mypage.com/segment#456. Incorrect link and redirect when clicking.
  • The Method generateUrlForPageWithSiteConfiguration of the class PageLinkBuilder checks if the TypoScript setting config.baseURL is set. If it is not set, then the URL is rendered incorrectly to the root-URL.
  • Setting config.baseURL resolves the problem. The link will then be rendered correctly.
  • However: As far as I can see, it is not possible to easily work with SiteConfigurations and BaseVariants with the config.baseURL-Setting.
  • If I am not mistaken, one would have to use e.g. TypoScript-Conditions for each variant to set config.baseURL. This seems pretty cumbersome. It is also not very nice to introduce lots of conditions depending on the URL into your setup.
  • Either there is a configuration method, that I have not considered yet, or the config.baseURL should be changed to be able to dynamically set it.
  • Or adjust the generateUrlForPageWithSiteConfiguration method?
Actions #1

Updated by Philipp Seiler almost 4 years ago

  • Description updated (diff)
Actions #2

Updated by Philipp Seiler almost 4 years ago

For now I will use .env-Variables to set a custom TypoScript baseUrl-Constant, which in turn will then be used for config.baseURL. Works, but again, seems cumbersome.

Actions #3

Updated by Benni Mack almost 4 years ago

  • Status changed from New to Needs Feedback

Hey Philipp,

this is actually expected behavior. TYPO3 does not (and cannot) know that you set a `<base>` tag yourself.

Setting config.baseUrl dynamically was possible (or is still possible) with TypoScript conditions. It is also possible if you use a hook to dynamically set TSFE->baseUrl.

The <base> tag isn't respected by a lot of crawlers, resulting in a lot of errors in your server log, so the recommendation is to work with config.absRefPrefix which is set dynamically from the site configuration.

Can you explain why you need the <base> tag?

Actions #4

Updated by Philipp Seiler almost 4 years ago

If I remember correctly, I needed it because of dynamically created Anchor-Tags that point to some elements on the current page. Without the base-tag, the anchor-links would trigger a site-reload, the desired behavior however was to jump directly to some anchor.

I do use TypoScript conditions now to set the correct base-tag.

I guess this problem this is somewhat of an edge-case and can probably be discarded.

Actions #5

Updated by Benni Mack almost 4 years ago

  • Status changed from Needs Feedback to Closed
Actions

Also available in: Atom PDF