Here's a patch to let other modules define additional handlers.
example usage:
/**
* Implements hook_views_summarize_handlers().
*/
function my_module_views_views_summarize_handlers() {
return array(
'my_module_views_summarize_hours_min' => t('Hours and Minutes'),
);
}
/*
* Implementation of hook_theme()
*/
function my_module_views_theme() {
return array(
'my_module_views_summarize_hours_min' => array(
'variables' => array('data' => array()),
),
);
}
/**
* Theme: format minutes as hours minutes
*/
function theme_my_module_views_summarize_hours_min($variables) {
$data = $variables['data'];
return '<div class="label">' . format_interval(array_sum($data),2) . '</div>';
}
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | views_summarize-1448384-4.patch | 2.09 KB | drasgardian |
| hook_views_summarize_handlers.patch | 2.9 KB | john morahan |
Comments
Comment #1
light9 commentedJust thank you for this path. Works for me!
Comment #2
oadaeh commentedI've done quite a bit of updating to fix a number of bugs. Would you mind updating your patch with the current code?
Also, do you have anything I can test this out with, so that I know it's working?
Comment #3
lionsharz commentedwhat does this patch do? i was looking for a way to subtract the Row Count Sum from one view from another (separate) view. This isn't normally possible given limitation of merging / combining views but perhaps this patch allows other modules to pull views summarize data(?)
Comment #4
drasgardian commentedThe attached patch should apply to the latest dev
Comment #5
letrotteur commentedWorks great! Thank you so much for this patch.
Comment #6
oadaeh commentedComment #7
oadaeh commentedI'll be putting this in the new 7.x-2.x branch, so as not to disrupt people who are fine with what has been working for them.
Comment #9
oadaeh commentedI've committed this. I added a README.txt (which is a good idea on its own) to include the example usage (which I had to correct due to a bug).
Comment #10
oadaeh commentedComment #11
oadaeh commentedComment #12
oadaeh commentedHmm, the system does not seem to be giving @John Morahan credit, even though he's checked.