Download & Extend

menu trails for /user page and /user/[uid] pages

Project:Menu Trails
Version:6.x-1.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Issue tags:user

Issue Summary

How hard would it be to add menu trails for user pages so they could go under a "people" tab, but if you are looking at your own user page, it would go under "My account". Right now, all of our user pages are showing up under "my account", which is a primary menu item we have. I assume this is because /user/[uid] seems like a child of /user to drupal by default?

Comments

#1

does this make sense?

#2

Seconded - it would be a great help to be able to show the link to /user as "active" when the current page path is /user/[uid]/foo/bar etc :o)

#3

Subscribe :)

#4

Just a hint, don't have time to look further at that time: May be this can be done by implementing hook_user() in menutrails.module like this:

<?php
function menutrails_user($op, &$edit, &$account) {
 
// Only interested in the user view op
 
if ('view' != $op) {
    return;
  }

 
// Do user-related stuff necessary for setting menu trail/breadcrumb here
}
?>

#5

I've got the following to work for the user view and for the user edit.

<?php
function menutrails_user_location() {
 
// This should only fire if the menu isn't already active.
 
$item = menu_get_item();
  if (
db_result(db_query("SELECT count(mlid) FROM {menu_links} WHERE link_path = '%s' AND module = 'menu'", $item['href'])) == 0) {
   
$href        = 'user';
  }
  else {
   
// We may want to do some breadcrumbing.
   
return $item;
  }
  if (!empty(
$href)) {
   
$item['href'] = $href;
    return
$item;
  }
  return
FALSE;
}

function
menutrails_user($op, &$edit, &$account) {
  switch (
$op) {
    case
'view':
    case
'form':
         
$item = menutrails_user_location();
          if (
$item) {
             
menu_set_item(NULL, $item);
          }
    break;
    default:
  }
}
?>

For the tracker module, I added the following line to tracker.pages.inc at the top of the tracker_page function:

<?php
module_invoke
('menutrails','user','view');
?>