Below function removes $item['options']['unaltered_hidden'] if a menu item is not for FIRSTCHILD like https://www.drupal.org/project/menu_inject_block
However, it may be altered by another module. The line should be removed.

Reminder: the hook is only used when adding/changing a menu link and saving it in the database.

/**
 * Implementation of hook_menu_link_alter().
 */
function menu_firstchild_menu_link_alter(&$item, $menu) {
  if (@$item['module'] == 'menu') {
    if ($item['link_path'] == '<firstchild>') {
      $item['options']['alter'] = TRUE;
      $item['options']['unaltered_hidden'] = $item['hidden'];
    }
    else {
      unset($item['options']['unaltered_hidden']);   // <-- This should be removed.
    }
  }
}

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

johnv created an issue. See original summary.

johnv’s picture

Title: Interferes with other modules. » Menu Firstchild interferes with other modules
johnv’s picture

Title: Menu Firstchild interferes with other modules » menu_firstchild_menu_link_alter() interferes with other modules
Status: Active » Needs review
FileSize
1.17 KB

Please see attached patch, that corrects hook_menu_link_alter. THis hook is called when saving a menu link from the menu overview form.

It contains:
1- A correction of the routine interface as mentioned in #1816870: Drupal 6 usage of menu_link_alter() - D7 doesn't pass $menu to it.
2- A typo (?) in @$item['module'] as mentioned in #2564287: typo in menu_firstchild_menu_link_alter() ?
3- Removes fiddling with $item['options']['unaltered_hidden']. The menu item may not be yours. It could be if is replaced,

I know, issues should not be mixed, but this issues queue is rather small, and all changes are very close together.

Chris Matthews’s picture

Status: Needs review » Reviewed & tested by the community

The 3 year old patch in #3 applied cleanly to the latest 7.x-1.x dev snapshot and works well for me so changing the status to RTBC.

  • anrikun committed 95539dc on 7.x-1.x authored by johnv
    Issue #2564289 by johnv: menu_firstchild_menu_link_alter() interferes...
anrikun’s picture

@Chris Matthews
Could you review the latest 7.x-1.x to ensure everything is ok for a new stable release?

anrikun’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.