Custom Contextual Links Module
Jan 09 2012
In the Drupal community the phrase “There’s a module for that” is pretty much synonymous with Apple’s “There’s an app for that”. So it was a bit surprising when "Trent":http://imagexmedia.com/trent, ImageX’s ‘walking module encyclopedia’, mentioned the lack of an existing module allowing developers to add links to the contextual links widgets in Drupal 7. There are a number of Drupal 6 modules that create a nice shortcut to edit/delete a node or to configure a block without actually clicking through the entire menu structure. Developers that used any of these modules immediately added them to their own personal ‘must install’ module lists and as a result, and much to the delight of the community, this became a core feature in Drupal 7. On it’s own the core module adds contextual link widgets to nodes and blocks and there are a number of modules that add their own links as well. Previously, the only way to add custom links was to create another smaller module (a step that a large part of the community wanted to be able to skip). So this is where the idea for a Custom Contextual Links (CCL) module came in... to give administrators an interface to add custom links that can be attached to nodes and blocks. *Version 1.0* The first version of the module had a relatively limited set of features. With it developers were able to create links that attached to either: * All nodes * All nodes of a specific content type * One specific node * All blocks * A specific block The ability to use a node id token in link path was also added as a bonus. This works in connection with links attached to nodes and allows one to create dynamic links in connection with node objects. *Version 1.1* One of the first responses after the release of the stable version was in regards to the custom token. "Lullabot’s":http://www.lullabot.com/ "Jeff Eaton":http://twitter.com/eaton who had previously written an article in "Module Mondays":http://www.lullabot.com/articles/module-monday-custom-contextual-links pointed out that it would make more sense to use core tokens. So this was first in a list of changes to implement to help improve the module. "Scott Jordison":http://twitter.com/circuscowboy then recommended attaching links to views (This, by the way, is a shining example of why the Drupal community is so awesome. Instead of just requesting this feature Scott supplied a constant stream of patches that added this feature to CCL.) Now you can attach your custom link to: * All views * All displays of a specific view * A specific display of a view These suggestions prompted a rewrite of the core of CCL to make it more modular. This involved removing the ability to add links to blocks and putting them into their own sub-module. The same applied to the views option. The last thing to add was the ability to quickly publish/promote/sticky a node through the contextual widget. This feature might need extra attention in the future but for now you can attach a link to: * Publish/Unpublish * Promote/remove to/from front page * Make sticky/unsitcky * To nodes (all, by content type or specific). Users will only be able to see these links on nodes where they have the ‘update’ permission. The final result looks like this: *Version 1.?* So what else is there to add? One thing on the agenda is to make all the settings exportable through features (time didn’t allow for this in Version 1.1). Revisiting access settings and looking into integration with rules is also an option to explore. Have suggestions of your own? "Try out":http://drupal.org/project/ccl the latest version of "CCL":http://drupal.org/project/ccl and give your feedback.
Learn from us
Sign up and receive our monthly insights directly in your inbox!