Creating Menu Items on the Fly

The Menus administration form is one place where you can create menu items (see Working with Menus: Administration Form). But when you create or edit a node, you also have the option of creating a menu item for the node, right within the node creation form.

On the go!

For example, you create a node with company information, and want a link to that node to appear within a menu you've earlier created and titled 'site menu'. You could create the node, head to the Menus administration form, and then create a new menu item within that 'site menu' menu.

The alternate way to do the same: When you create the new node, you can create a menu item right then and there. On the form for creating your node ('Submit Page', 'Submit Story', or whatever it happens to be), look under 'Menu settings'. There you can set the following three properties (and in Drupal 5, a Description of the menu item as well):

Menu link title

Input the title of the menu item. That's what will appear within the menu.

Parent item

What menu will this menu item appear inside? Choose one here.

The pop-up list shows your existing menus and all of their menu items. You can simply select the title of a menu to have your new menu item inserted at the normal "top level" of that menu, or you can select a menu item to make your new menu item a "child" sub-menu item of that "parent" menu item.

Weight

As discussed in Working with Menus: Administration Form, "weight" is an older and somewhat clunky way of setting the order of items within a menu. A much easier method is to ignore weight, and later order your menu items with simple drag-'n'-drop. Head to the linked page for more info.

What's the path?

The above on-the-fly menu item creation is similar to creating a menu item using the Menus administration form, with one key difference: Here you don't need to set a path for the menu item. You're creating a menu item for the node you're in the midst of creating, so of course the menu item will automatically link to the node's path!

Further editing

Want to later edit the menu item you've created (or delete it, or move it, or whatever)? No problem. Use the regular Menus administration form.

Restricting on-the-fly menus

As noted above, when making a menu on the fly, you can place it under any menu or menu item that appears in the "parent item" list (which should be all of the menus and menu items in your site).

But if you have multiple users allowed to create content, you may want to restrict their placement of on-the-fly menu items into just one menu. For example, if you allow users to submit news articles to your site, you might restrict them to creating on-the-fly menu items under a menu called 'news stories', and not under other menus on your site.

To do this:

Navigation » Administer » Site building » Menus

Click the 'Settings' tab.

In Drupal 6, the pop-up list 'Default menu for content' lets you select which menu will be the default choice for users who create menu items on the fly.

In Drupal 5, at the bottom of the form under 'Content authoring form settings', you'll see 'Restrict parent items to:'. Here you can set the single menu to which on-the-fly menu items will be restricted. (Keep it at 'Show all menus' for no restrictions.)

Overall, this is an esoteric detail that many sites won't need to worry about at all.

Add new comment