1

I have a node created (using Default content) as part of the site install and it is available to edit at node/[nid]/edit. However, this node holds some of the site-specific content (for example, content to display on sitewide banner) and should be available under the site configuration section instead of node/[nid]/edit so that I can restrict the edit access with specific permission.

Why not the configuration/settings form? Because the node type has rich fields like image upload, entity reference, etc, and would be nice to use the node/entity's field API and display modes.

Is there a way to get the edit page of just this node at /admin/config/system/banner-settings?

1

Create a new menu item in a custom module

# mymodule.routing.yml

mymodule.banner_settings_form:
  path: /admin/config/system/banner-settings/{node}
  defaults:
    _entity_form: node.edit
    # Copy UUID from exported default content.
    node: 05d6a9e5-6e78-42bb-b3fe-b9a6344f4022
  requirements:
    _entity_access: node.update
    # Custom permission check.
    _permission: 'administer site banner configuration'
  options:
    _admin_route: true
    _node_operation_route: true
    parameters:
      node:
        type: 'entity:node'
        # Part of jsonapi module.
        converter: paramconverter.jsonapi.entity_uuid

Visiting /admin/config/system/banner-settings would take the default UUID value from the route and renders the form.

P.S: After saving the form it would redirect back to node/[nid] and this can be avoided by passing ?destination=<your path> in the link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.