I have been working with the taxonomy menu with 'Custom Path' for menu path type. The requirement for this is to create a view with page display and path defined, in my case the view path is 'products' with taxonomy term as argument. No issues here.

I am using the Menu Block module to be able to show only the submenu items of the level 1 menu items. This works without any issue, for instance with the navigation menu. But the problem is that the custom taxonomy menu does not actually build the menu, therefore, in the menu_router table, there is only one router path defined as 'products/%' and this i beleive is generated by the view rather than the taxonomy menu.

So this is an issue when using the Menu Block module which calls the menu_tree_page_data function which then calls the menu_get_item(). Now in menu_get_items(), the function generates all the ancestors for the path but when it tries to find the route_path for each path in the ancestor array, in the menu_router table, of course it doesn't find but one which is 'products/%'. So when the item is return to the menu_tree_page_data, the $item['href'] will equal 'products' for any menu item that is generated by the Taxonomy menu of Custom Path type.

This makes it impossible for menu_tree_page_data to identify the parents of the menu item.

Menu Block cannot therefore generate a menu tree for second level menu items.

So I was troubleshooting and found where the problem lies and this is in the menu.inc for the menu_tree_page_data function, and making the modification as below fixed the problem:

(THIS WAS JUST FOR TESTING PURPOSES AND I DIDN'T KEEP THE CHANGES MADE TO CORE)

my modification is where there is lots of space between lines, in two places

function menu_tree_page_data($menu_name = 'navigation') {
  static $tree = array();

  // Load the menu item corresponding to the current page.
  if ($item = menu_get_item()) {
    // Generate a cache ID (cid) specific for this page.


/***********CHANGE HERE*************************/
  $path = $_GET['q']; //added
    //$cid = 'links:'. $menu_name .':page-cid:'. $item['href'] .':'. (int)$item['access'];
    $cid = 'links:'. $menu_name .':page-cid:'. $path .':'. (int)$item['access']; //added



    if (!isset($tree[$cid])) {
      // If the static variable doesn't have the data, check {cache_menu}.
      $cache = cache_get($cid, 'cache_menu');
      if ($cache && isset($cache->data)) {
        // If the cache entry exists, it will just be the cid for the actual data.
        // This avoids duplication of large amounts of data.
        $cache = cache_get($cache->data, 'cache_menu');
        if ($cache && isset($cache->data)) {
          $data = $cache->data;
        }
      }
      // If the tree data was not in the cache, $data will be NULL.
      if (!isset($data)) {
        // Build and run the query, and build the tree.
        if ($item['access']) {
          // Check whether a menu link exists that corresponds to the current path.

/***********CHANGE HERE*************************/
         //$args = array($menu_name, $item['href']);
         $args = array($menu_name, $path);//added

Since menu_get_item() never gets passed the optional 'path' argument and ends up using the default value of $_GET['q'], is it ok to make this modification in the menu_tree_page_data function? If not, has anyone had this problem and is there a better solution?

Any help is greatly appreciated and I hope that I have described the issue as clearly as possible.

Comments

BM’s picture

Project: Drupal core » Menu Block
Issue summary: View changes

forgot the second line I commented out //$args = array($menu_name, $item['href']);

BM’s picture

Issue summary: View changes

typo

BM’s picture

Issue summary: View changes

code used

jthorson’s picture

Project: Menu Block » Drupal core
Status: Active » Closed (won't fix)

If the contrib module isn't passing $path, then your issue lies with the contrib module.

Making this modification to core might solve your issue, but is not a long term solution ... it will get wiped out during your next core upgrade, and your change may introduce other problems that won't be caught since nobody else is running/testing this change in core.

The way to get this resolved is to determine which contrib module isn't passing $path, why it isn't passing $path, and then file an issue against that contrib module.

BM’s picture

Project: Drupal core » Menu Block
Version: 6.22 » 6.x-2.2
Component: menu system » Code
Category: support » bug
Status: Closed (won't fix) » Active

moving Project

BM’s picture

Priority: Normal » Major

Please it would really be great if someone looked at this, I believe this is a limitation or an overlooked bug.

BM’s picture

Priority: Major » Critical

The issues is with the "menu block" module used with the "taxonomy menu" module, for menu that starts on the 2nd level. In the "menu block" module, the function menu_tree_add_active_path calls menu_tree_page_data() from menu.inc to find the menu items that are in the active trail, but the problem is that the menu_tree_page_data() does not return any menu_item with the link['in_active_trail'] set to true even for those that are in the active trail, for menus built with the "taxonomy menu" module and menu block set to 2nd level.

Please see the hack I made to menu.inc in post number 1 to test this.

Please I really need some guidance on this, and if anyone can create a patch for the menu block module to address this issue. I am very surprised no one has posted anything about this issue.

I am changing the priority to critical because I am not getting any response, and hopefully someone will catch this nuisance.

Thank you.

BM’s picture

Issue summary: View changes

typo

Dave Reid’s picture

Priority: Critical » Normal
JohnAlbin’s picture

Status: Active » Closed (won't fix)