I've added a menu item with path mysite to my site's secondary links. However, when accessing MySite, its parent item is not activated and thus the secondary menu is not shown. The breadcrumb doesn't contain the parent item either. What am I doing wrong?

CommentFileSizeAuthor
#4 mysite_menus.gif22.14 KBsos4nt

Comments

agentrickard’s picture

I don't know. Does the user have permission to 'view all mysite pages'?

sos4nt’s picture

Does the user have permission to 'view all mysite pages'?

Yes, the user does have all MySite permissions.

The primary (and secondary) menu isn't even set when linking to a specific MySite page (e.g. mysite/1/view) rather than mysite.

Maybe this is a problem with the Drupal menu system itself. Do you set the menu path (... > mysite > mysite/1/view) from within MySite or is it determined by Drupal automatically based on the path name?

BTW, I'm running Drupal 5.1.

agentrickard’s picture

The path is set in mysite_menu(). http://therickards.com/api/function/mysite_menu/MySite

Are you saying that you assigned the 'mysite' menu element to a parent (like 'somepath'), so that the menu request is for 'somepath/mysite'?

I think this is a quirk in menu handling, but don't really know enough. Can you screenshot the menu settings page for the MySite menu item you made?

sos4nt’s picture

StatusFileSize
new22.14 KB

Here you go. Nothing special about the menu item settings.

The primary links are like:

  • Home (node/12)
    • MySite (mysite)
    • My Account (user/{uid})
    • ...
  • 2nd item
agentrickard’s picture

Maybe your Home link should be to '/' (empty path) and you need to configure node/12 as the home page under site settings?

Looking at node_menu(), I suspect that the path node/12 is only active is certain cases:

    // Error pages must to be present in the menu cache and be accessible to
    // all. More often than not these are individual nodes.
    for ($error_code = 403; $error_code <= 404; $error_code++) {
      if (preg_match('|^node/(?P<nid>\d+)(?:/view)?$|', drupal_get_normal_path(variable_get('site_'. $error_code, '')), $matches) && ($node = node_load($matches['nid']))) {
        $items[] = array(
          'path' => 'node/'. $node->nid,
          'title' => t('View'),
          'callback' => 'node_page_view',
          'callback arguments' => array($node),
          'access' => TRUE,
          'type' => MENU_CALLBACK,
        );
      }
    }
sos4nt’s picture

I cannot assign an empty path to a menu item. However, when I set Home to <front> and configue node/12 as the default front page, the Home menu isn't activated when accessing "/", let alone /mysite. Maybe this is a bug in the menu system...

sos4nt’s picture

It's getting confusing.

First of all: I've overlooked the default MySite menu item in Navigation. After deleting that item my custom MySite menu item worked, i.e. its parent item was activated! The item itself was not activated since its path is still /mysite and not /mysite/{uid}/view. I think one would have to alter the global menu array to get this right, but that is a minor issue.

However, after a while my menu item's name changed to "View all custom sites". Apparently my menu item was disabled and another menu structure was created:

  • Home
    • MySite (/mysite) <- my custom item
    • MySite (/) <- the new item
      • View all custom sites (/mysite/all)

Could you please point out, where these menu items are created (and how to prevent it)?

agentrickard’s picture

http://therickards.com/api/function/mysite_menu/MySite

I think that all you need to do is this:

1) Delete your custom menu items
2) Move the MySite default menu items from Navigation to your Secondary Links menu.
3) Rename the links (optional)

You can't remove the menu items from mysite_menu(), because they register the functions needed for MySite to work. See http://drupal.org/node/10901 for more details about menus.

What are you trying to accomplish?

agentrickard’s picture

BTW: custom Drupal menu items should not have either leading or trailing slashes.

sos4nt’s picture

My site's layout has primary and secondary navigation. The navigation items are highlighted depending on the current page. MySite has to be a secondary item and when accessing MySite, it's menu item (and the parent item) should be highlighted.

Moving the MySite item from "Navigation" to "Primary links" did the trick. I still have to alter the global menu (renaming path "/mysite" to "/mysite/{uid}/view") to make Drupal highlight the menu item, but that's okay.

Maybe I change my site's layout and make MySite the front page...

Thanks for your help.

agentrickard’s picture

Status: Active » Closed (fixed)