"But that's easy in Drupal, isn't it?"

Many a time a customer’s casual challenge of “But that’s easy in Drupal isn’t it?” has resulted in us taking up the gauntlet and putting in some hard yards to indeed "make that easy”.

Clearly 8,500 D7 modules on drupal.org is not enough.

As we were working on a government project last year the question popped up again and we had to rise to the occasion. The project was eventually put on ice, but during its course another module baby was born. We called it Views Aggregator Plus and set her free in Drupalland. It seemed a waste not to share it.

One thing we've learned about releasing modules: you have no idea upfront which ones will thrive. We thought we had created a niche application and planned for one install, namely that single install on that site that never happened. But the module usage statistics prove that it has found applications way beyond its initial purpose. Not bad for a module that wasn't meant to see the light outside that one web site!

As so often in Drupal, further enhancements were very much driven by the needs the community raised, thus taking the module into directions we’d never anticipated, like its application as a Webform submissions post-processor.

For your inspiration we contacted some of the early adopters we came to know through the module's issue queue and collected from them some examples of how Drupal site builders all over the world get value out of Views Aggregator Plus.

We hope you enjoy the screenshots and explanations below. Among these may be just that thing you also needed to be easy in Drupal.

Special thanks to Nick Veenhof of Acquia and Mads Bordinggaard Christensen of Rillbar Records who happily shared screenshots and application stories.

Example 1

by Nick Veenhof of Acquia

"My View displays a list of Search Cores. I configured the module to apply grouping on the customer name. The aggregation functions applied on remaining fields were summations on the column cells of selected fields. This is how the Document Count and Query Count columns were created."

 

 

 

Example 2

by Mads Bordinggaard Christensen of Rillbar Records

"My company is primarily a wholesale distributor of music on vinyl and CD’s. After each quarter I have to send out statements to all the different Record labels who deliver their products to us. The attached PDF is an example of a dummy record company, presenting the amount of sold items within the period.

Dummy Records have 2 different products in their catalogue. The CD has sold 32 items and the vinyl 20 within the period. These sales are however spread out on 6 different orders. So instead of having 6 table rows representing each order, I can use Views Aggregator Plus to compress and group the rows using a unique value, in this case the product SKU.

Before using Views Aggregator Plus each order of the given product had its own line, and it quickly became very unclear and messy. Some products sell a lot of items, but maybe only 1 or 2 on each order, so it can quickly result in a lot of rows (especially for the record labels who had to sum the amount of sold items in order to make an invoice for me).

So Views Aggregator Plus is a really important factor in creating these statements to our suppliers. Apart from that it allows us to quickly pull an exact amount of sold items from the database within a given period (using the date range as a contextual filter)."

 

Example 3

by Rik de Boer, founder of flink

Lastly the use-case for which Views Aggregator Plus was initially developed.

"I've illustrated the construction of the VAP View (bottom) through two intermediate phases, both normal Views. The top one shows a number of government projects (names omitted) by industry, their budgets and their durations (a duration is a Date field with start and end values).

After enabling the Views PHP module a PHP code snippet field (see below) was added to turn the date ranges into more readable keywords: "not started”, “underway” or “closed”. A copy of the PHP field was added thus creating an identical column (with a different title) in preparation for the next step.The duration column was excluded from display.

For the final View the format was flicked from “Table” to “Table with aggregation options”. The “Industry” field was grouped (compressed) and tallied, the budget value field was group-summed.

“No. projects underway” had the “Count (having regexp)” aggregation function applied with “underway” as the regular expression to count. The same aggregation function was applied to “No. projects closed” except that this time the counting parameter was “closed".

To make the “Totals” row, column sum functions were added for all fields except the first. And finally sorting was enabled… voila!"

  <?php
    $start_date = strtotime($data->field_field_duration[0]['raw']['value']);
    $end_date   = strtotime($data->field_field_duration[0]['raw']['value2']);
    echo time() < $start_date ? 'not started' : (time() < $end_date ? 'underway' : 'closed');
  ?>
File under: 

Pedal to the Drupal metal: Views Accelerator

Read More »