Redirect to custom path per node

Created on 27 January 2023, over 1 year ago
Updated 4 October 2023, 9 months ago

Problem/Motivation

Add custom redirect path field per node for content types. The field itself is enabled or disabled via checkbox in the content type configurations for Unpublished nodes redirect in admin. If enabled, chosen unpublished node can be redirected to custom path, different from the specified for the content type. When the field is disabled, we use the path from the content type configuration.

Proposed resolution

Added new field for custom per node path to redirect to in Entity class.

Created .module file to implement:

  • hook_entity_base_field_info() in order to add the custom redirect path field to all content types.
  • hook_form_alter() in order to alter add/edit forms and hide the field for where custom field is disabled.

In UnpublishedNodesRedirectUtils.php added helper functions:

  • To get node types with disabled custom redirect per node.
  • Get the form IDs for entity type add/edit forms.

In On403Subscriber Event added:

  • Check if custom field is enabled and if its value is not null, then use custom path over the one from content type redirect entity configuration.
✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇧🇬Bulgaria borislav_mihaylov_bulcode

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024