Redirect to custom per node path

Created on 30 January 2023, almost 2 years ago

Problem/Motivation

Add custom redirect path field per node for content types. The field itself is enabled or disabled via checkbox per content type in its configuration in Unpublished nodes redirect in admin. If enabled, chosen unpublished node can be redirected to custom path, different from the one 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 to all content types.
  • hook_form alter() in order to alter add/edit forms and hide the field for where it 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

Active

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024