Development

Show Menu Description Field in Node Add/Edit Form

Many components in Drupal have an optional title or description field. This text usually displays when a user hovers over an item. We had an interesting request: a client wanted to have a box that displayed text which would change every time you roll over a menu item. This can be accomplished using just a small amount of jQuery, and Drupal’s built-in menu handling. The menu system in Drupal can handle descriptions on each menu item, however you have to do this through the menu admin. The problem is that the client needed to be able to edit these descriptions at will.

We’ll use Drupal’s hook_form_alter() function to add the node’s menu description field (really the title attribute) right into the node’s add/edit form. We must also use the node_form_submit() function to submit the value.

Unsure how to use this code, or where to put it?   Perhaps you need to look at Creating a Custom Module.

Leave a Reply

Your email address will not be published.