Provide a way to extend/modify Top Bar Items

Created on 27 December 2024, 3 months ago

Problem/Motivation

As part of 📌 Define the 3 areas the Top Bar will provide Active , the 3 new regions for the Top Bar were defined, and the way to add items to them. However, it can be tricky to modify or extend the content of those regions by 3rd party modules

Steps to reproduce

Proposed resolution

A possible approach to achieve this in a generic way would be to follow a similar approach as widget plugins do:

  • Provide a generic hook_top_bar_item_alter hook that would allow to modify all the items
  • Provide a more specific hook_top_bar_item_TOP_BAR_ITEM_alter that would allow an specific top bar item plugin

Remaining tasks

Discuss the approach
Implement it

User interface changes

None

Introduced terminology

TBD

API changes

TBD

Data model changes

None

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

navigation.module

Created by

🇪🇸Spain plopesc Valladolid

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

Comments & Activities

  • Issue created by @plopesc
  • 🇨🇭Switzerland berdir Switzerland

    This specifically started from 📌 [PP1] Show entity information on the Top Bar Postponed . By default, we'll show title and published/not published for an entity. But if you use content moderation/workspaces, you might want to show the moderation state or thee current workspace or something like that instead. And contrib might want to add more features.

    I'm not sure if an alter hook is the answer for that. It's a plugin system, it already comes with a plugin alter hook. content_moderation can alter the default entity info plugin and show the moderation state, it's just a question of how much code we have to duplicate in that plugin.

    But such alter hooks, both on the plugin and on render arrays tend to run into conflicts if multiple modules want to change things.

    I'd suggest we finish the referenced issue and then have a specific follow-up for content moderation to tie unto that. In core or I'm also open to exploring that in moderation_sidebar, but at least the basic information seems like something that core should provide.

  • Status changed to Closed: works as designed 27 days ago
  • 🇨🇦Canada m4olivei Grimsby, ON

    The referenced issues here are now fixed, eg.

    📌 Define the 3 areas the Top Bar will provide Active
    📌 [PP1] Show entity information on the Top Bar Postponed

    We also had a follow up issue to bake in the moderation state if available:

    Display content moderation state in the Navigation Top Bar Active

    I believe that has resolved the point at issue that inspired this issue. As @berdir pointed out there is some baked in ability in the plugin system to alter / override things.

    I'm going to Close this issue for now. If further situations come up that further illustrate the need for some better DX, we can revisit.

Production build 0.71.5 2024