Project:Menu Breadcrumb
Version:6.x-1.1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi,
In particular, I'm interested in generating a node's path based on it's placement in a menu (primary links).
Using Pathauto, we can set node path based on replacement patterns using tokens. Two of the available tokens are:
[menupath] & [menupath-raw] "The menu path (as reflected in the breadcrumb), not including Home or [menu]. Separated by /."

I thought that if I used the Menu Breadcrumb module to show the breadcrumb, then the token would pick this up and use the menu path for the node title. But that doesn't seem to work.

So, I'm wondering if there's something I'm missing, or some way of making sure this module plays nicely with that token. Is this possible, or am I thinking about this all wrong?

Cheers!
:) Scott

Comments

#1

I'm having the same issue... after some snooping around I think I can point out the two problematic areas found in both the token and menu_breadcrumb modules, but haven't been able to fix them yet.

token
The global $_menu doesn't seem to exist, which kills any hope to find a trail.... i'm thinking maybe it's a leftover from D5?...

//token_node.inc
function node_token_values($type, $object = NULL, $options = array()) {
  ...
  global $_menu;

  $trail = array();
  $trail_raw = array();
  $original_mid = token_menu_get_mid('node/'.$node->nid);
     
  $mid = $original_mid;
  while ($mid && $_menu['visible'][$mid] && $_menu['visible'][$mid]['pid'] != 0) {
    array_unshift($trail, check_plain($_menu['visible'][$mid]['title']));
    $mid = $_menu['visible'][$mid]['pid'];
  }

  // One more time, unfiltered
  $mid = $original_mid;
  while ($mid && $_menu['visible'][$mid] && $_menu['visible'][$mid]['pid'] != 0) {
    array_unshift($trail_raw, $_menu['visible'][$mid]['title']);
    $mid = $_menu['visible'][$mid]['pid'];
  }
  ...
}

menu_breadcrumb
The page during which pathauto tries to determine a path for node/xx is actually node/xx/edit, therefore the lines below will query for the menu in which node/xx/edit is found, which of course fails.

//menu_breadcrumb.module
function menu_breadcrumb_init() {
  ... 
  $menu_item = menu_get_item();
  $menu_link = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $menu_item['href'])));
  ...
}

I don't think I'll have time to actually look much deeper into this, so I hope someone smarter than me will fix this mess. :)

#2

I should really do my research before starting to dig through code..... It's all fixed for me when using the token dev version. >_>;

#3

Status:active» closed (fixed)

Marking closed based on Proct0t's report that a more recent token module fixes the issue.

Thanks Proct0t.

nobody click here