Drupal 7: Views Ctools Dropbutton Module

David G - DrupalIf you look through alot of the Drupal administrative UI you will see see drop buttons used all over the place! They conserve space while offering many choices to the end-user. I was taking a module with hardcoded business logic, reporting and a user-interface and I wanted to try to make it more generic and leverage a view for the same report. A critical piece of the UI is the use of drop buttons. Luckily I found the Views Ctools Dropbutton module!

A example of a dropbutton is generic user interface (technically taken from a Drupal 8 issue):

Example of generic dropbutton in Drupal 8.

Example of generic dropbutton in Drupal 8.

The Views Ctools Dropbutton module creates a views_field_handler for a faux field to use within Drupal Views. This means you can create a dropbutton as seen above and power label and link destination from Fields used within your View. Typically, you would exclude from display the fields to be used as dropbutton links. Then you add a global: dropbutton and assign the links to be cherry-picked fields from your View.

As an illustrated example — here is a View configuration that lists Person(s) in a View that are related by some criteria to eachother:

Basic views configuration of fields for a View that makes use of a dropbutton.

Basic views configuration of fields for a View that makes use of a dropbutton.

The Ctools Dropbutton can then be configured used to make use of links (such as NIDs linked to content, or any ID overriden to output as a formatted link):

Configure the Dropbutton to make use of FIelds which are configured as links.

Configure the Dropbutton to make use of FIelds which are configured as links.

So our final example view will look as follows with Dropbutton and all! Woo!

Example output of final View making use of the configured dropbutton.

Example output of final View making use of the configured dropbutton.

So this module allows the use of Views to create richer administrative forms as a single use-case for the module.

Also, worth noting is that about a week ago not just any link could be placed within the dropbutton. I actually submitted a patch to the module to support any Field formatted as a link to be placed into the dropbutton. This functionality has been included in the 7.x-1.2 version of the module.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *