Problem/Motivation
Follows #3624760: Plan: consistent Display Builder entry points in the Navigation top bar.
That plan gives every page one entry point per layer that built it: the page layout, the main content display or its override, and the Views page display. All of it renders in the Navigation module's top bar.
A site not running Navigation gets none of it. The per-entity override is still reachable through its local tasks, but the page layout, the bundle display and the Views page display have no entry point from the page they render, which is the problem #3624760: Plan: consistent Display Builder entry points in the Navigation top bar set out to fix.
Proposed resolution
The list itself is already UI agnostic: hook_display_builder_page_displays() fills a PageDisplays collector with a title, a scope, a URL and a weight, and the top bar item is only one consumer of it. A second consumer is small.
Options, to decide in this issue:
- A block plugin listing the entries. Works with any theme and any admin chrome, and site builders place it where they want.
- A tab for core's Toolbar, for sites that use it instead of Navigation.
- Neither, and state in the documentation that these entry points need Navigation.
Remaining tasks
- Pick the option.
- Access is checked per builder URL by the consumer, so whatever renders the list repeats that.
- Test: the entries show without Navigation installed.
- Document what needs Navigation and what does not.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 3625979 after.png | 319.39 KB | csakiistvan |
| #11 | 3625979 before.png | 565.81 KB | csakiistvan |
Issue fork display_builder-3625979
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pdureau commentedCan we avoid adding a feature request to beta8 scope that close to completion?
Comment #3
mogtofu33 commentedSure.
Comment #4
pdureau commentedWhen I proposed avoid adding a feature request so late in beta8, I meant "so late in beta phase". We are so close to 1.0.0 completion than any new feature is a risk.
Anyway, it is not a big deal. beta9 has been released though, so I am changing the tag.
Comment #5
pdureau commentedThe block will be useful only when being positioned in the front theme, so the discoverability is low. I am afraid we would add afeature which will not be usable.
This is my preference, to keep thinks simple on our side.
Worth a little investigation. Maybe inspired from https://git.drupalcode.org/project/devel/-/blob/5.x/src/ToolbarHandler.php
Comment #6
pdureau commentedI will give a try, it may look like that:

Comment #8
pdureau commentedTo review. I am still not sure it is a good idea, but I am not against it.
Code changes: some logic is extracted from
DisplayTopBarItemtoPageDisplaysTraitbe shared withToolbarHooks.To test, you need to do uninstall
navigationand to installtoolbar.I have have hesitated to position the display menu at the end of the toolbar, alongside "Edit", because it is also a contextual menu. What do you think?
Comment #10
csakiistvanComment #11
csakiistvan✅ Tested and works — with Navigation uninstalled and Toolbar enabled, a node with an overridable display had no Display Builder entry point in the Toolbar; after applying MR !517 and rebuilding caches, a "Display" tab shows in the Toolbar and its tray lists "Customize this content". Sites on the core Toolbar get an entry point too.
I pushed a functional test,
ToolbarDisplayTest: the tray lists the page displays in order, and there is no tab on a page without one or for a user without builder access. The first case fails withoutToolbarHooks.Notes
routecache context to core's render-cachedtoolbarelement, so the whole Toolbar is now cached per route instead of per permission set.<script>in the tray does not run under a CSP without'unsafe-inline', and relies on the tray being inside.toolbar-tab.Comment #12
csakiistvanComment #13
pdureau commentedIt was done like that in purpose. Toolbar items are one-liners.
It is a bit the reverse situation of https://www.drupal.org/i/3625978#comment-16819927 where a
addCacheContexts(['user.permissions'])was considered redundant in amenu_local_tasks_alterhook. Here, it is considered missing. In both case, permission cache context is already added byAccessResultand/or the renderer.So, i would prefer not messing with anything here.
CSP as "Content Security Policy"? Drupal core sends no CSP header, but I will have a look.Comment #14
pdureau commentedIf the CSP assumption fails, the only effect is that core's tab-switching bug comes back #3529674: Toolbar tab behavior is inconsistent when clicked.. Let's not mess with our codebase while the risk is not a security one, and the fix is expected in Core.
Back to RTBC.
Comment #16
mogtofu33 commentedToolbar is deprecated in 11.5 and removed from core in 12.0.0, both due the week of December 7, so I prefer not to add a feature on it right before 1.0.
The tab adds no public API and can land in 1.1 if a Toolbar site asks for it, so !517 stays here until then.
Before it lands, the route cache context needs an answer: it reaches core's toolbar element, so each URL stores a full Toolbar, admin pages included.
#3529674: Toolbar tab behavior is inconsistent when clicked. has also moved to the contrib Toolbar queue, so that fix will not come from core, and
ToolbarDisplayTestwill needdrupal/toolbaron Drupal 12.For now I offer
3625979-toolbar-supportwith small change indocs/install.mdto recommend Navigation and says what is missing without it.Comment #18
pdureau commentedOK. Good to know. I remove from
1.0.0the scope.Do we close as won't fixed?
Comment #19
mogtofu33 commentedI prefer postponed as
admin_toolbarusage is still very high, so could be something we want to provide at some point.