Get rid of node_page_top()

Created on 7 February 2023, about 2 years ago

Problem/Motivation

Follow-up from 🐛 Fix hook_page_top implementation for node.module Fixed .

node_page_top() runs on every request, just in case we're on a node preview route, to add the form above the preview.

I think it ought to be possible to change the preview route to include the markup currently being added in node_page_top() - i.e. put this in the controller one way or another.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

10.1

Component
Node system 

Last updated about 5 hours ago

No maintainer
Created by

🇬🇧United Kingdom catch

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

Comments & Activities

  • Issue created by @catch
  • 🇬🇧United Kingdom longwave UK

    Controllers return output that is wrapped into the main content block in page.html.twig. page_top is for things that get printed outside of the normal page wrapper, but maybe the main content block could bubble this up to the top level somehow?

  • 🇬🇧United Kingdom longwave UK

    I thought about this some more; we already allow ['#attached']['html_head'] to add things to <head>, so why not allow ['#attached']['page_top'] to put things in the page top?

  • Status changed to Postponed: needs info about 1 month ago
  • 🇦🇺Australia acbramley

    This is a fairly common pattern in core, contrib and custom code. We have 6 implementations in core (block, navigation, node, system, update, toolbar) that all do some variation of checking route, request, or user permissions to add stuff to the page.

    Is this really that much of an overhead or something that shouldn't be done?

  • 🇬🇧United Kingdom catch

    Navigation and toolbar both add their markup on every page, for me that's a good use of the hook.

    System and update add it for all admin users on all admin pages, that's again close to 'site-wide' and seems OK, although to a large extent it's compensation for not having dashboard module or similar in core.

    Block's implementation is very similar to node's - it's adding some specific markup for a specific route, for me that should also be done in the route controller one way or another. Feels like a symptom of both block and node preview being very ancient. Moving back to active but yes it's not the worst thing in the world so downgrading to minor.

Production build 0.71.5 2024