Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make usage of absolute links configurable #506

Merged
merged 6 commits into from
Apr 24, 2020

Conversation

sebastian-meyer
Copy link
Member

@sebastian-meyer sebastian-meyer commented Apr 23, 2020

In multi-domain environments like the Zeitungsportal we need the option to force all links to be absolute. Since TYPO3 9.x the Typoscript configuration option config.absRefPrefix only effects links generated by Typoscript, but doesn't work globally.

This Pull-Request introduces new extension-wide configuration options to force all generated links to be absolute. In addition it allows using HTTPS as default scheme for those URLs.

The default is to not use absolute links, so existing instances should behave exactly like before.

@sebastian-meyer sebastian-meyer added the ⚙ feature A new feature or enhancement. label Apr 23, 2020
@sebastian-meyer sebastian-meyer self-assigned this Apr 23, 2020
sebastian-meyer and others added 2 commits April 23, 2020 17:28
albig
albig previously approved these changes Apr 24, 2020
Copy link
Collaborator

@albig albig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this seems to work but keep in mind:
With TYPO9.5:

  • You need a site-configuration with a base including scheme+domain. Without this the links keep to be relative. Providing "/" as base will change nothing with these settings and won't make absolute URLs.
  • If you have no HTTPS scheme provided in the site-configuration, it won't be force by this setting.
  • Don't know, what is happening with TYPO3 8.7.

As it shouldn't break anything, we can merge this even if it won't work as expected in all situaltions.

@sebastian-meyer
Copy link
Member Author

That's how it is intended to work:

  • If you have configured a base URL and HTTPS scheme in the site-configuration, those do not automatically lead to TYPO3 generating absolute URLs everywhere. The typolink function will still generate relative links as long as you don't set the forceAbsoluteUrl parameter. So that's where the new extension settings come into play.
  • If you haven't configured a base URL and/or HTTPS scheme in the site-configuration, you can't expect TYPO3 to generate absolute URLs even with the new settings.

But you are right, I should make it clearer, that having a proper site-configuration is required for using the new extension settings.

@sebastian-meyer sebastian-meyer merged commit 77fa835 into kitodo:master Apr 24, 2020
@sebastian-meyer sebastian-meyer deleted the allow-absolute-urls branch April 24, 2020 15:17
}
return $content;
$conf['parameter'] = $altPageId ?: ($this->pi_tmpPageId ?: 'current');
$conf['additionalParams'] = $this->conf['parent.']['addParams'] . HttpUtility::buildQueryString($urlParameters, '&', true) . $this->pi_moreParams;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildQueryString() is unknown in TYPO3 8.7.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I'll fix it in a separate pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚙ feature A new feature or enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants