Introduce the concept of "specificity" for MENU_LOCAL_TASK and disallow "duplicates"

Created on 26 January 2010, about 15 years ago
Updated 28 January 2025, 26 days ago

In a custom module I have a hook_menu implementation with the following entries:
(adapted for better understanding. "xxx" was actually "mlid/%menu_link")

xxx : MENU_CALLBACK
xxx/under-construction : MENU_DEFAULT_LOCAL_TASK
xxx/add/page : MENU_LOCAL_TASK
xxx/add/%node_type : MENU_LOCAL_TASK

The intention:

  1. On xxx/under-construction, I want to see two tabs: The active one ("under construction") and the one for xxx/add/page.
  2. On xxx/add/page, I want to see two tabs: The active one ("add page") and "under construction".
  3. On xxx/add/webform, I want to see three tabs: xxx/under-construction, xxx/add/page, and xxx/add/webform.

For 1) and 3) this works as intended, just for 2) I see a duplicate tab for "xxx/add/page". Obviously, the first is created for the router item "xxx/add/page", and the second one is for "xxx/add/%node_type".

So, my thinking:
- Yes, I am using the system in a legitimate way. Router items with different argument masks are allowed to coexist.
- There is no point in having two tabs with the same link path. The more explicit router path (with fewer "%") should have priority, the other should be ignored.

Technical obervation:
The most important things happen in menu_local_tasks(), around this place:

<?php
    while ($item = db_fetch_array($result)) {
      _menu_translate($item, $map, TRUE);
      if ($item['tab_parent']) {
?>

(my line numbers are probably incorrect due to some patching)

I have not tried this with D7, so I set the version to 6.x-dev. Feel free to change this, if you can confirm it for D7 !

✨ Feature request
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

menu system

Created by

πŸ‡©πŸ‡ͺGermany donquixote

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 smustgrave

    Thank you for sharing your idea for improving Drupal.

    We are working to decide if this proposal meets the Criteria for evaluating proposed changes. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or there is no community support. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024