We have moved to Github. Please open tickets there.

Opened 23 months ago

Closed 21 months ago

Last modified 19 months ago

#3681 closed Defect (fixed)

Name collisions when registering to different sections of a menu

Reported by: ewinslow Owned by:
Priority: high Milestone: Elgg 1.8.1b
Component: Core Version: 1.8
Severity: minor Keywords:
Cc: brett@… Difficulty:

Description

If I register two menu items with the same name to different sections, they will both appear as options.

E.g. I was trying to override the "profile" menu item to switch it to the "alt" section, so I just registered the menu item with the name "profile", but that didn't work, it just showed up twice.

Current solution is just to manually unregister the previous menu item before re-registering the new one.

Change History (6)

comment:1 Changed 23 months ago by cash

Here is the current state of things:

  1. A menu item name is unique for a section. The last registered menu item with a name takes precedence.
  1. Menu items with the same name can be added to different sections of the same menu or to different menus. A menu item can have the same name as an ancestor or descendant.
  1. Only one item per menu may be "selected" by default.

Some of this wasn't explicitly designed.

Solutions to your report:

  • do nothing but document this
  • only allow one menu item per menu with same name. Precedence goes to last registered item.
  • add a function for modifying a current registered menu item or returning a reference to the menu item

comment:2 Changed 21 months ago by brettp

This might not be the case any more because of changes to the menu system. Will need to check if it's still exists.

comment:3 Changed 21 months ago by cash

  • Milestone changed from Needs Review to Elgg 1.8.1b
  • Priority changed from normal to high
  • Version changed from 1.8 Beta to 1.8

The changes to the menu system fixed this but broke using the same name in different sections. Looks like the name is now being treated as being unique. For example, the admin area has a "utilities" section for both the Administer and Develop areas. Now, you can only see one of those depending on what plugins are active (and probably the order).

comment:4 Changed 21 months ago by ewinslow

I think the names need to be unique to a menu. Let's call those adminutils and devutils or something.

comment:5 Changed 21 months ago by Cash Costello

  • Resolution set to fixed
  • Status changed from new to closed

Fixes #3681 fixed Utilities menu collisions in admin section and added documentation about registering more than one menu item with the same name to a menu

Changeset: 710b17aa37dd5c90db695219defdfef7a889f29a

comment:6 Changed 19 months ago by Cash Costello

Fixes #3681 fixed Utilities menu collisions in admin section and added documentation about registering more than one menu item with the same name to a menu

Changeset: 710b17aa37dd5c90db695219defdfef7a889f29a

Note: See TracTickets for help on using tickets.