Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
node system
Priority:
Minor
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Feb 2023 at 11:09 UTC
Updated:
6 Mar 2026 at 10:35 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
longwaveControllers return output that is wrapped into the main content block in page.html.twig.
page_topis 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?Comment #3
longwaveI 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?Comment #5
acbramley commentedThis 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?
Comment #6
catchNavigation 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.
Comment #7
catchComment #9
acbramley commentedRan with the idea in #3 a bit, I'm not sure on the implications of allowing page_top and page_bottom in HtmlResponseAttachmentsProcessor. I tried playing around with unsetting them in buildPageTopAndBottom with a pass by reference on $main_content but that didn't work.
Setting to NR to gauge how viable this would be.
Comment #10
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #11
acbramley commentedComment #12
smustgrave commentedTested this out on a local 11.x install with standard profile
Verified that preview is still working
1. Created a random basic page content type
2. Clicked preview and it was correctly rendering
Only thing I see is if a CR could be created about the new parameter
Thanks
Comment #13
acbramley commentedI still want a review of the approach before creating a CR
Comment #14
oily commentedRe: #3:
There are lots of good reasons to 'add things to
<head>' whatever PHP framework you are using. I think that having a piece of the page dedicated to the node preview form was originally because it was felt that the importance of the form markup was sufficient to justify it getting 'red carpet treatment' ie special real estate on the page?I am not quite sure if the net effect of the refactoring is that node preview form will lose its special status or if there will be a danger of it competing with other markup that might affect UX? Are there any other issues to consider like performance? Other questions are whether the form ever really needed its special status and if it did then, whether it does now.
At the end of the day I think the question is so long as the UX is pretty much the same whether this will make page rendering more susceptible to bugs.
Comment #15
smustgrave commented@acbramley had a chance to look at this today and I don't see anything wrong with the approach you are taking.
Comment #16
acbramley commentedCRs added, not sure if we should/need to make the new parameter optional since this method is public API.
Comment #17
smustgrave commentedYea think we will have to make it optional. Did a search for buildPageTopAndBottom and modules like Google Tag (all be it in a test) and Canvas both have references (even though they don't do anything with it). Think it would be kind to not break them if possible.
https://git.drupalcode.org/search?group_id=2&scope=blobs&search=buildPag...
Comment #18
acbramley commentedShould be good to go now
Comment #20
smustgrave commentedBumped to 11.4 and rebased
Believe all feedback for this one has been addressed
Comment #21
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #22
acbramley commentedAgreed with your changes, marking this back to RTBC since they are fairly trivial.
Comment #23
alexpottI just realised we need to add documentation for these new attachment keys in the correct place. Added a comment to the MR>
Comment #24
alexpottAlso we should add a follow-up to convert \Drupal\block\Hook\BlockHooks::pageTop() (I think this is the only other implementation in core that would lend itself to this pattern)
Comment #25
acbramley commentedCreated #3571143: Convert BlockHooks::pageTop to attachment in BlockController::demo for the follow up.
Comment #26
acbramley commentedMoved the comments.
Comment #27
smustgrave commentedFeedback from @alexpott appears to be addressed
Comment #28
alexpottComment #29
alexpottCommitted and pushed 07f90f1f3d7 to main and b73b9291c84 to 11.x. Thanks!
Comment #33
acbramley commentedNice! Do we publish the CRs now? I'm not sure if that process has changed.
Comment #34
alexpott@acbramley thanks for the reminder - no the process has no changed.
Comment #36
nod_Updating search link from #17: buildPageTopAndBottom