Module Monday: Custom Contextual Links

How to Add Custom Links to an Entity's Context Menu in Drupal 7

With Drupal 7's contextual menus, it's easy to pull up edit forms and other management screens for specific entities like nodes, comments, and views. Just mouse over the entity in a list, and you'll get a dropdown menu of contextual options. Adding your own custom links to an entity's context menus, however, can't be done out-of-the-box. Custom Contextual Links changes that; it allows you to add any link to the context drop-down for supported entity types!

Screenshot of the Custom Contextual Links administration screen

Setting up Custom Contextual Links is easy. The module adds its own screen to the administrative configuration section. Adding a new link gives you a set of simple options to control the link's title, destination URL, and where it should appear. For now, it supports adding links to specific blocks, all blocks, specific nodes, specific node types, and all nodes simultaneously. It's a little detail, but the module's administration UI does a good job of hiding unnecessary options using Drupal 7's new States API.

Screenshot of the contextual link in action

Once the link is set up, everything is ready. Jump back to a page that features the node or the block in question, mouse over it, and you'll see the new option in its contextual dropdown menu. Custom Contextual Links is a relatively new module; it was released less than a week ago, but it's stable and easy to use. It's a great tool to streamline the administrative and editorial navigation process!

Get in touch with us

Tell us about your project or drop us a line. We'd love to hear from you!