I'm using primary links for a top-level menu and secondary links for a node hierarchy menu local to the page you are viewing. My issue is that a given page's parent node may be a member of both the primary links menu and the secondary links menu. When I choose the node hierarchy fieldset option "Create Menu" for a new child node pointed to such a doubly-listed parent, the new menu item will always be generated in the primary links menu. What I really want is for it to be created in the secondary links menu.

A work-around for me was to add "ORDER BY mlid DESC" to the _nodehierarchy_get_menu query around line 1036. This makes the selected menu for the parent item that which has the most recently created menu item for it. I recognize that this is less than ideal. :(

Is there a better way to do what I'm trying to do?? What if there was some kind of option to say "Preferred menu in case of tie" on the settings?

Comments

StevenWill’s picture

I think the "Preferred menu in case of tie" is a good solution for this issue. This would be very helpful for my situation.

capellic’s picture

I have the same problem. I changed this function:

/**
 * Find the menu ID for the given node.
 */
function _nodehierarchy_get_menu($nid) {
  return db_fetch_array(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", "node/$nid", 0, 1));
}

to:

/**
 * Find the menu ID for the given node.
 */
function _nodehierarchy_get_menu($nid) {
  return db_fetch_array(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND menu_name = 'primary-links'", "node/$nid", 0, 1));
}