05
May
May
Drupal Views Handler integration with Views Aggregator
05 May
Posted by Bogdan Views/ Views Handler/ Aggregation
Drupal Views Handler allows you to bring data from other database tables without needing a relationship. In this article we will build a handler that counts a query result that afterwards will be integrated with Views Aggregation to obtain a total.
In order to build a View Handler, first you need to build a custom module. Into the .info file you should add the following.

In the example.module the hook_views_api() must be added.

hook_views_data() must be declared in example.views.inc

Now we can start building the handler example_count_handler.inc

After the handler is built it can be used in whichever View you want to use it in. The handler is added like any other field into the View fields.
Once the handler is added you may need the total of the results counted for each row. The Drupal Views Aggregator can be used for this part.
On the main Views UI page, under Format, instead of Table, click Table with aggregation options.

Check the Apply column function. In this situation we need the Sum but there are many other possibilities, like Max, Min, Count etc. Also you can decide where you want to place the Total column.

After following the steps mentioned above, you should have something like:

Enjoy!
In order to build a View Handler, first you need to build a custom module. Into the .info file you should add the following.

In the example.module the hook_views_api() must be added.

hook_views_data() must be declared in example.views.inc

Now we can start building the handler example_count_handler.inc

After the handler is built it can be used in whichever View you want to use it in. The handler is added like any other field into the View fields.
Once the handler is added you may need the total of the results counted for each row. The Drupal Views Aggregator can be used for this part.
On the main Views UI page, under Format, instead of Table, click Table with aggregation options.

Check the Apply column function. In this situation we need the Sum but there are many other possibilities, like Max, Min, Count etc. Also you can decide where you want to place the Total column.

After following the steps mentioned above, you should have something like:

Enjoy!
Category View
Tags
activities
Aggregation
amazon
android
apache
API
appcelerator
application
assistant manager
backup
balance
brand recognition
business days
cache
camp
coding standards
command
commerce
community
context
cURL
customer engagement
customer portal
database
data integrity
deployment
developer
Drupal
drupal 7
drupal 8
Drupal Camp
Drupal Core
Drupal development
Drupal solution
Drush
e-commerce
events
filter
front-end developer
game
games
general
git
Global Training
google maps
integration
ios
job
Job fairs
jobs
kpi
maintenance
manual testing
memcache
mobile
mobile app
mobile application
mobile development
Module
modules
mysql
open source
Panels
performance
php
php developer
plans
project
project manager
promotion
qa
Quality Assurance
redis
registry
Relation
release candidate
remote team
responsibilities
responsive
screen resolutions
Scrum
Security
server
Services
session
skills
software
software testing
sprint
stock management system
studio
support
Targul de Cariere
team
team building
teambuilding
teamwork
testing
titanium
tutorial
Târgul de Cariere in IT
Unit Testing
update
Updates
usability
user experience
varnish
Views
Views Handler
web application
web application testing
web development
webservice
webshop
website usability