Simplify how to redirect from one node to another node or URL

Created on 8 September 2023, 10 months ago
Updated 20 March 2024, 3 months ago

Problem/Motivation

We have migrated to D9 and were having trouble creating redirects from one node to another when the first node was unpublished. In the end we worked out it was because were weren't using the node/NID path instead of the alias as used to work in D7 (as discussed in https://www.drupal.org/project/redirect/issues/2821158 πŸ“Œ Document that URL redirects work from node/{nid} but not alias Needs work ).
This lead to some investigation on how we can improve the UI for our clients when managing redirects from old content to new and we have come up with adding some additional functionality to the URL Redirects section of the node edit page.

Proposed resolution

After the table where the redirects from a relative URL to the node are displayed is a new button so that a Redirect from this node to another URL can be easily added.
If there are any redirects from this node to another URL these are retrieved using a Drupal\redirect\RedirectRepository::findBySourcePath call. When there are redirects from this node to somewhere else, both the Add URL Redirect and new Redirect to another URL buttons are not displayed.

Remaining tasks

We don't use content in multiple languages so I would imagine there is more work to do to add support for redirects to different URLs based on the language?

User interface changes

Adds a new button to the URL redirects section:

And if there are redirects from this node to another URL displays them while removing the Add buttons:

I think using the table may or may not be the correct way to go. Possibly if there is just a single redirect then it should be displayed a different way and only use the table if there are multiple redirects for multiple languages?

✨ Feature request
Status

Active

Version

1.9

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom altcom_nh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024