Rebuilding taxonomy menu breaks all menu blocks that use the menu. This is because Taxonomy Menu basically removes all menu items and recreates them when a rebuild is requested (or some important setting is changed for the vocabulary). This assigns new mlids for the recreated menu links. Also, Menu Block saves the parent menu with a menu-mlid pair.

Would it be possible to use menu-path pair to identify the menu parent instead? I think the patch for that should be fairly easy to make, assuming that this doesn't break any other use cases and that paths are unique within a menu. Is this an option at all?

Thank you in advance.

CommentFileSizeAuthor
#2 menu_block-path_lookup.patch6.5 KBJasu_M
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jasu_M’s picture

An idea for a solution: use both mlid and path for identification. This way, an update script doesn't have to be written and the changes will even be backwards compatible, keeping reverting to previous versions possible. The data format is now menu:mlid, this could be changed to menu:mlid:path, which is also compatible with the current code too (list($menu, $mlid) = explode( ... is used for reading). Then, mlid could be used as the primary method for fetching the item, and path as secondary.

Also, I checked, paths are unique within a menu.

Jasu_M’s picture

Here's a patch (it's a recursive CVS patch, affecting menu_block.module and menu_block.admin.inc) even though I received no reply for this issue.

It does the following:
1. Tries to look up parent menu item by mlid.
2. If step 1 fails, tries by link path + menu name
3. If step 2 succeeds, saves to avoid double query the next time.

Admin page is changed so that it functions even if mlid is invalid, and also to save the path as well.

The format the string is saved in is also backwards compatible - older version of the module can be used with the new format as well (ie. rolling back to an old version works).

Is the patch fine as it is, and can it be integrated into the codebase?

Best regards,

Jasper Mattsson

temp’s picture

please attach patched file - i don't have ssh access
thanks for this feathure.

JohnAlbin’s picture

Status: Active » Postponed (maintainer needs more info)

assuming that this doesn't break any other use cases and that paths are unique within a menu

While its a good idea that paths be unique in a menu, its not a requirement. So we can't uniquely track the links by their path.

Rebuilding taxonomy menu breaks all menu blocks that use the menu.

That's definitely not true. Only blocks that have been configured to use a specific menu item as their root would break. I never use that feature. Its only in the module because of repeated requests for that feature. You almost always want to use the default "<root of MENU>" option for whatever menu you want and then select the "Starting level".

Perhaps you are misconfiguring all your menu blocks?

Dave Reid’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

No response in four years, closing.