Add configuration options for dynamic block titles

Created on 30 September 2016, almost 8 years ago
Updated 7 November 2023, 11 months ago

Problem/Motivation

Different sites and use-cases require different titles for various menu blocks. Menu blocks might want a variety of dynamic titles based on the menu.

Proposed resolution

Add configuration options to the MenuBlock block plugin to set the block title to any of the following:

  • Block title (Drupal default behavior)
  • Menu title
  • Fixed parent item's title
  • Active item's title
  • Active trail's parent title
  • Active trail's root title

See also #2950943: Add links to menu parent block title β†’

Remaining tasks

  1. Review
  2. Commit
  3. Release

User interface changes

New settings on the configuration form for the MenuBlock.
Different titles on menu blocks based on the configuration.

API changes

No real public changes. Adds a bunch of protected methods to the MenuBlock plugin. Overrides the constructor and adds a create() method.

Data model changes

None. New config is stored as block config, as expected.

Release notes snippet

TBD.

Original report by @noah

When showing second level menu items in a menu block, the D7 version allowed me to use the parent menu item link title as the block title by leaving the "Block title" field blank. With the D8 version, I'm not able to leave the "Block title" field blank, and I'm not able to determine what token should appear there so that the parent menu item link title appears as the block title. I see that "Block title as link" is listed as a missing feature, which makes me think that dynamic block title (unlinked) is possible, but I'm just not seeing how -- is there a way of making this work yet?

✨ Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada noah

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States banoodle San Francisco, CA

    This functionality does not exist in the current 1.10 release. It also doesn't exist in the latest Dev branch.

    Was this functionality removed? I could really use it.

  • πŸ‡ΊπŸ‡ΈUnited States alison

    @banoodle I think your best bet is to open a new issue -- possibly linking to this issue for context!

    (That said, I still see the functionality in the module code and in my site usage. Make sure you have the "Display title" checkbox checked in the menu block settings form, just as a starting place -- that checkbox shows/hides the new "Use as title" field, which is inside the "Advanced Options" fieldset. But if you still don't see the setting, I recommend opening a new issue, maybe with the "support request" category (or "bug report").)

Production build 0.71.5 2024