Project

General

Profile

Actions

Feature #91018

open

Automatically convert Links with "external" URLs to same site to t3-links (page,file, etc.) in RTE transformation / link wizard / command?

Added by Sybille Peters almost 4 years ago. Updated 8 months ago.

Status:
Accepted
Priority:
Should have
Assignee:
-
Category:
Backend API
Start date:
2020-04-14
Due date:
% Done:

0%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

I think it is a common phenomenon, that editors copy URLs out of the site and use it for the links. This may be especially true for large sites where it is tedious to click through the page tree in the link wizard.

The downside is:

  • these links will break if the URL changes. Even if there are redirects, it is not necessary to redirect in this case and it does have an unnecessary performance and load impact.
  • these URLs are more permanent. The page id will not change, the URL may change.
  • will not work for translated pages, e.g. when the content is translated you have to change the links. If these were page links they would automatically already point to the translated page

There is already an extension which does these conversions but it currently does not work for RTE: https://github.com/georgringer/uri2link/

Also, I am wondering, why do this at a later point? Why not do it when the link is created:

  • e.g. in the Link wizard. Either automatically convert the external URL link to page link in the link wizard or via a button. Make this configurable if this should always be done, be done in control of the editor or not at all.
  • or, on RTE -> DB transformation

The conversion should work for RTE field and non-RTE fields.

In any case it would be good to additionally have a wizard or command line tool which does the conversion for old content.

Actions #1

Updated by Georg Ringer almost 4 years ago

  • Status changed from New to Accepted
  • Target version set to Candidate for Major Version

Just some additional notes:

Editors often use this ways because:

  • They lack permissions to access certain parts of the website
  • It is not possible to link to records, e.g. news records
  • The don't find the page in the tree

The linked extension does the remapping at this point because there is no earlier way to hook into.

Some things which need to covered with new solution:

  • linking to records
  • info to editor that link changed
  • improved handling of parameters, including L=
Actions #2

Updated by Sybille Peters 8 months ago

  • Subject changed from Automatically convert Links with "external" URLs to same site to page links in RTE transformation or link wizard? to Automatically convert Links with "external" URLs to same site to t3-links (page,file, etc.) in RTE transformation / link wizard / command?
Actions #3

Updated by Sybille Peters 8 months ago

I have a working solution in private extension currently (this is a cli command though, it does not convert in link browser or RTE transformation). It would need some more work to make the specialized things more configurable.

These are some additional things which could be considered:

- pages may have redirects (via page type, redirects, others means ...), so it is best to follow these to the final target. What I did was actually do a request with following redirects. This also made sense because some links linked to other sites in the organization which redirected back to the main site. This is however, a bit costly, I think using a cli command is better here than doing that on-the-fly in the BE.
- you need to consider languages: if linking to a page with same language, you don't need the language parameter, if linking to page in other language, you usually do, even if it's the default
- detect if fields are rich text and support t3 links or make configurable in which table/fields/content types there will be conversions?
- what I did is have a configurable number of transformations which would run sequentially, e.g.:

1. normalize (if necessary), e.g. resolve path URLs starting with / or non-/ (legacy) to create a full http(s) URI
2. follow redirects (and check if target URL available), get target URL
3. convert target URL to t3 link (consider language, if not file URL)

drawback with redirecting: you can't handle target pages/content which is hidden.

Actions

Also available in: Atom PDF