3

Here's some paths I'm using in my module

  • control (this isn't really a page, it just goes to the next item)
  • control/jobs (provides list of jobs)
  • control/jobs/% (path for editing a particular job)
  • control/download (separate page)
  • control/settings (separate page)

I would like a simple menu that shows jobs, download and settings. I would like it to add the 'active' class when visiting the page. And when visiting a particular subpage (e.g. a particular job), I would like the parent menu items to have an "active-trail" class or such.

Using hook_menu I've created these menu items, all as MENU_NORMAL_ITEMs and I've put them in a new menu called menu-control. I've added this menu's block to my page. I get the menu items listed. But when I visit a particular job, there is nothing to indicate I'm on a child page of 'jobs' (or indeed, 'control').

This seems like the simplest implementation of a menu and I've been hacking at it for weeks (on and off!). Can anyone help?

1
  1. Take a look at the Views Module. You can define your page view and attach it any menu.
  2. Define it with a path such as control/%/jobs and set it to provide a list of all jobs using filters and format settings Set the menu type as menu tabs, and give it a name.
  3. Add additional pages to the same view and with paths such as control/%/job and use a contextual filter to read the value in the URL in the % wildcard position. (You may have a bit of trouble if the wildcard is multiple words due to spaces vs. dashes in the path. If so ask another question here). Set the menu tab for this item as well.

Menu tabs are the menu that appears above the content (user Admin has View and edit tabs for content pages). Note that you must have two menu tabs for them to show.

Your pages for download and settings sound like they require user input. Those pages will require either an add-on module or custom coding to design a form.

  • thanks for taking time to answer. However I'm not sure I was clear enough. I don't want all the jobs (there will be hundreds) actually listed in any menus, I just want the menu ancestry or "trail" to be highlighted so the user knows what section they're in. It so simple/basic. At first I thought the tabs would work, but no joy there either. – artfulrobot Nov 28 '11 at 8:53
  • You may be referring to breadcrumbs. Breadcrumbs are attached to the menu system although I have not really addressed them. There are also several modules (drupal.org/search/apachesolr_multisitesearch/breadcrumbs) that might give you better control. – Ashlar Nov 28 '11 at 16:50
0

It was(is) a bug!

The patch at entry #262 on that page applies and works for me on Drupal 7.10.

Thanks for contributions/answers.

0

I guess you are trying to get the breadcrumb navigation working properly. Maybe the Menu Breadcrumb module can help? Here is an excerpt about it from the module's project page:

By default, Drupal 6+ use the Navigation menu for the breadcrumb. This module allows you to use the menu the current page belongs to for the breadcrumb.

As an added bonus, it also allows you to :

  • Append the page title to the breadcrumb (either as a clickable url or not).
  • Hide the breadcrumb if it only contains the link to the front page.
  • Generate the breadcrumb from the URL structure if content does not belong to a menu (7.x-1.6 and older only).
  • nope. standard menus. I want just top ("Control") and second ("List", "Download", "Settings") level links listed, but I want the appropriate ones highlighted when it or a child page is being viewed. – artfulrobot Nov 28 '11 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.