Having recently returned to Drupal development after a little hiatus I dove into Categories, Views and Panels with wild abandon. I've having some trouble implementing non-drupal-standard style menu navigation with working breadcrumbs, however. Instead of having a single Navigation menu, I prefer to set my sites up with section navs in the primary navigation and then sub-navigation in separate, section-specific menu blocks that are only visible in the correct section. Click on "About Us" see an About Us menu with History, Contact Info and Legal information, for example. My problem is trying to ge this to work with breadcrumbs in general and Categories specifically. The issues around Categories and hidden containers have been documented, but even before this there are issues with having to have the navigation linked to menu options within the Navigation menu.

How have others dealt with this? What are some good recipes for having navigation based on Primary Nav section liks with section-specific sub-navs?

Thanks,

Ethan

Comments

gollyg’s picture

I had the same issue. I have got it working using a custom php snippet. I use this from the page.tpl.php file, but it can be added to a custom block.

tip: Whatever approach you take do not try to modify your menus to get this to work! That's whats driving your breadcrumbs, and they also seem to constantly change when you are using the category module if they are outside the primary links menu (or whatever menu you have defined as containing your primary navigation).

So try this:

    $localNav = _menu_get_active_trail();
    if($localNav[1] && $user->uid != 1) {
      $local = theme_menu_tree($localNav[1]);
    	if($local):?>
        <div class="block" id="localNav">
        <h2 class="sidebarTitle">Current Section: <strong><?php $currentHeading = menu_get_item($localNav[1]);print $currentHeading['title'] ?></strong></h2>
    	  <?php print $local; ?>
        </div>
      <?php else: ?>
        <div class="sidebarTitle"></div>
  	  <?php endif;

The html can be customised to whatever your want it to be. It basically looks for the active current menu which, if you are working with a strict hierarchical structure, should always be your primary links for an anonymous user. You dont need to modify your menu structure for this to work.

You could refine it to check for the primary links menu, and only build the block if the current page fitted within that structure. I have not had any need to do that yet, but it would be a simple if statement.

The test for $user->uid==1 checks for admin, it gets a bit ugly when your admin menu pops up twice. You may want to change this.

This works of a standard primary links menu, so you dont need to muck around with your menu structure.

hth

venkat-rk’s picture

ethanw, there is indeed a way out. Steps:

  1. Create a menu called 'About Us' at administer>>menus>>add menu
  2. Go to administer>>settings>>category, click on 'Menu item settings' and choose 'About Us' as the default menu and save the changes
  3. Go to administer>>categories and create a new container. Make sure this is a hidden container
  4. Now create the category structure for the 'About Us' section using containers and categories. Create an 'About Us' container, with History, Contact info and legal as the categories. This container should have the hidden container as its parent.
  5. Go to administer>>menus, find the primary links menu, add a menu item called 'About Us', with the path being either the node id or the alias (if you are using cat_pathauto). Tick the 'Expanded' check box if you want the About Us menu to display expanded. Choose the parent item as 'Primary links'.
  6. Go to administer>>blocks, enable the 'About Us' block and configure it to show only on the 'About Us' pages and save the changes.

Repeat this process for the other primary links you want to show with a sectional navigation menu.

Sit back and enjoy lovely primary links leading to sectional navigation menus without breaking the breadcrumb trail, the prev/up/next navigation of category_display etc etc :-)

Note: This is based on the multiple root menus tutorial on Jaza's category web site. One word of caution- before you create each new sectional nav block, you should change the default menu at administer>>settings>>category>>menu item settings. Otherwise, your menu navigation links will land up in the wrong sectional menu. Also heed the other warning in the tutorial I referred to. But, that's a minor one.

gollyg’s picture

One word of caution- before you create each new sectional nav block, you should change the default menu at administer>>settings>>category>>menu item settings. Otherwise, your menu navigation links will land up in the wrong sectional menu.

does that mean that, after setting up your site structure, every time you edit a category or container you need to change the category admin settings?

I have found that when I update a page and have fiddled with the menus, the menu item is updated, in some cases incorrectly. This is not a minor issue, particularly when clients are updating the site. In fact I have taken to using the category menu module when I am creating the site structure, but disabling it after this point to avoid the above complication.

Interested to hear if this approach addresses this issue.

venkat-rk’s picture

does that mean that, after setting up your site structure, every time you edit a category or container you need to change the category admin settings?

I haven't tested extensively, but I am afraid yes, whether it is adding containers and categories or moving a category/container from one menu to another. In both cases, the default menu must be the one in which the new cont/cat should appear.

Your solution of disabling cat_menu after setting up the site structure is very interesting. I haven't needed to give users 'create categories' permission on any site so far, but I suspect the multiple root menus approach makes category less attractive for such sites, as you would also have to give users category admin permissions to allow them to set the default menu.

gollyg’s picture

Disabling category menu is not a perfect solution, but it was worked so far (still could run into issues). It is a pity that this feature, and some related ones, is so difficult to achieve in the category module. Its an awesome module and Jeremy has done an amazing job, but the category menu module seems to have some 'by design' features that arent that usable in practice.

If you have time give my snippet solution a try - it actually works perfectly without have to mess around with multiple containers. And, since it runs off the menu system, it works without the category module.

ethanw’s picture

I think it's going to be either driving the breadcrumbs etc. from a hidden menu or using a template function for me...switching the category menu seems like it could work, but I worry it'd spell disaster the second someone other than me tried to make changes to the site.

--
ethan winn
http://colab.coop

_craig’s picture

If you use taxonomy (in core), taxonomy_breadcrumb might help with the breadcrumbs...