If for instance, you create pages in the following menu tree:

  • About
    • History

The breadcrumb on both pages reads:

Home > Community

Where it should be:

Home > About

and

Home > About > History

respectively.

The offending code is in commons_core.module:674 in function commons_core_set_breadcrumb():

        if ($node = menu_get_object('node')) {
          // Make 'Community' the active menu item.
          $item = menu_get_item();
          $item['href'] = 'community';
          menu_set_item(NULL, $item);
          if (og_is_group_type($node->type)) {
            $breadcrumb[] = l(t('Groups'), 'groups');
          }
          else {
            switch ($node->type) {
              case 'notice':
                $breadcrumb[] = l(t('Notices'), 'notices');
                break; 
            }
          }
        }

This sets the active item on ALL nodes, where it should be only on content related to the community.

Comments

Sarenc’s picture

Thanks for posting this as it was the cause of other problems as well.

This code affected og_menu (which I think commons should include) by removing the active trail from the selected page making the active menu item not expand.

ezra-g’s picture

Issue tags: +Commons 2.6 radar

I'm tagging this for triage as part of the 2.6 release.

Lammert’s picture

I guess this would also solve the issue with the active-trail CSS class being set incorrectly to the "Community" Menu link. For more details, see: http://commons.acquia.com/discussion/menu-active-trail-defaults-communit...

ezra-g’s picture

Status: Active » Needs review
StatusFileSize
new2.06 KB

Thanks, everyone for the background information here.

The attached patch only sets the 'Community' item to active for nodes that are in organic groups, which also resolves the referenced in #3.

@tstackhouse I tested on a fresh install of Drupal 6 with nodes in the "Primary links" menu nested a=>b=>c and in fact the breadcrumb for C points directly to A. As a result, I believe the desired breadcrumb you're describing is a reasonable feature request - So that we can focus on alleviating the bug before the Commons 2.6 release, please file a separate issue for the feature request aspect of this issue.

I agree with @Sarenc that og_breadcrumb could be a good solution here. Making breadcrumbs more configurable is a benefit to site builders. In general, it seems like commons_core_set_breadcrumb could use some refactoring, at least from a code readability standpoint.

It would be great to get some testing of this patch. I plan to commit later today as we push towards a 2.6 release.

Sarenc’s picture

I tried out the patch but still having issues with og_menu (not og_breadcrumb! ;)

I guess our problem is the requirement of having two active trails, one for "community" and one for the actual page we are on. This isn't a problem for a default commons install. I'm going to explore this today and will report back.

Sarenc’s picture

After some research it seems our issue is a result of drupal core's inability to have multiple active trails. There is some (somewhat) related discussion here: #609542: Active trail isn't set on all menu items pointing to the current path.

We have enabled the page CT to be posted to groups. We also have og_menu installed so that group admins can have their own group menu where they can assign pages to. This works great for static pages related to the group - "About" and "History" are good examples. We also use og_user_roles to restrict this ability to group admins. I personally feel commons should include this type of functionality OOTB.

Long story short, any og-node assigned to a menu will not work as expected when menu_set_item() is used to set "community" as the active trail. This is a good example of a functionality that can be seen as a feature or bug depending on your perspective.

Our workaround is to preprocess_block() the og_menu block and rebuild the links with our own version of menu_tree_output() that double checks each link with:

if ($data['link']['link_path'] == $_GET['q']) {
  $data['link']['in_active_trail'] = TRUE;
}

Now we have the community menu item properly active as well as any og_menu items we are viewing. Whew that was a bit tough.

ezra-g’s picture

Status: Needs review » Fixed

Thanks for the detailed followup, @Sarenc! Please keep us posted about your customizations in a new issue.

I've committed this patch.
http://drupalcode.org/project/commons.git/commitdiff/3aea5fe

Automatically closed -- issue fixed for 2 weeks with no activity.