menus

Make Custom Menus Available to Content Types

Published April 2, 2011

With the introduction of Drupal 7, developers may encounter a puzzling problem involving custom menus: imagine that you have created a custom menu — such as a list of secondary links for the footer of a website — and at least one of its menu items is pointing to a node. You think of an improvement to that node's content, so you edit the node and save the results. But its corresponding menu item has disappeared from your custom menu, and has somehow reappeared on the Main menu! How did that happen?

Change a Menu Item's Path Before Unpublishing Its Node

Published March 25, 2011

Drupal developers of every level of experience understand that a menu item can point to any valid path, such as that of a node. But Drupal beginners can receive a nasty shock when they discover — usually the hard way — that changes to such nodes can result in unplanned and unpleasant changes to menus. Specifically, one of the more annoying traits of Drupal is the way a menu item disappears when its associated node is unpublished (or deleted, i.e., unpublished with extreme prejudice). This may be old news to Drupal veterans, but people new to this CMS can easily stumble into this pitfall.

Showcase a User's Comments with Views and Menu Tabs

Published August 27, 2009

By now, you should know and love the Tracker module that comes with core. It has its strengths, but many weaknesses. For one, you can't separate out posts from comments, or sort the list in interesting ways. Views can help you make exactly the list you want, and place it in a tab on the user's profile exactly like the "Track" tab.

For this example, you'll be adding a list of comments. Creating the view is simple enough:

  1. Clone the default view comments_recent, and call it comments_by_user
  2. On the Page display, add a Relationship for Comment:User

Module Development: Understanding Wildcard Loader Arguments

Published May 19, 2009

When writing a module from scratch (or trying to deconstruct one to figure out how it works), it might save you some time to be aware of "wildcard loader arguments" when using hook_menu(). These wildcard arguments are automatically linked with "_load()" functions that allow the module developer to load data into the argument anytime the menu item is called.

Here's a quick example of what I'm talking about. Look at this snippet from the Quicktabs module's quicktabs_menu() function: