courtly
courtly
courtly
courtly

Upcoming Events

San Francisco CiviCRM Meetup - February 8th, 2012
February 8th, 2012
Come meet others from the Bay Area who are interested in, using or developing (more...)

UK usergroup - London meetup
February 8th, 2012
Come and meet others from the UK that are using CiviCRM or are interested in (more...)

London user and administrator training
February 23rd, 2012
A comprehensive two day hands on training course covering the configuration, (more...)

CiviCRM London sprint Feb 2012
February 27th, 2012
Following the CiviCRM training here in London, we will have a CiviCRM code (more...)

Philadelphia - CiviCRM Meetup for Q1 2012
March 13th, 2012

UK South West - CiviCRM Meetup
March 20th, 2012
Come meet others from the Area who are interested in, using or developing for (more...)

[Bristol, UK] user and administrator training
March 21st, 2012
A comprehensive hands on training course covering the configuration, (more...)

San Francisco user and administrator training
March 29th, 2012
A comprehensive two day hands on training course covering the configuration, (more...)

CiviCRM Usability, Test and Code Sprint - San Francisco (March 2012)
March 29th, 2012
This usability, code and test sprint is targeted at CiviCRM users and (more...)

CiviCon 2012 San Francisco Bay Area - April 2nd 2012
April 2nd, 2012
CiviCon is THE annual event bringing together the people who use, develop, (more...)

CiviCRM Documentation, Test and Code Sprint - after CiviCon San Francisco (April 2012)
April 4th, 2012
This sprint is targeted at CiviCRM users and developers who want to work on (more...)

CiviCRM Components

Tools for engaging your supporters...

CiviContribute


CiviEvent


CiviMail


CiviMember


CiviReport


CiviCRM Drupal Views Integration

Not Just a Contact Database

These optional components give you more power to connect and engage your supporters.

  • civiCASE

  • Case management for clients and constituents.

  • civiEVENT

  • Online event registration and participant tracking.

  • civiMEMBER

  • Online signup and membership management.

  • civiMAIL

  • Personalized email blasts and newsletters.

  • civiREPORT

  • Report generation and template management.

January 12, 2009 - 14:18 — MalucoMarinero

I've started working with CiviCRM as I've been looking to build a new website for a NPO I work for, which does Youth Development onboard a Sail Training ship. One of the problems we face is the information we have being in multiple locations, so to get any critical information for our operations onboard (such as Passenger Manifests, Crew Transfers and other details) we have to go through the office. On top of this, alot of these things are STILL put together by hand via spreadsheets and what not, which can make for a slow process.

Implementing CiviCRM to start bringing all our membership information, event information and registration together could certainly streamline this process, but critical to this is quickly generating manifests, reports and what not so that whoever needs the data with the right login credentials can get it quickly with no fuss and just print it out. Views seemed the best way to do this as it's flexibility in displaying information queried from the database is excellent, as long as it's given good definition to work with.

Basically I've spent the last week or so relearning a bit about programming and improving CiviCRM's Views Integration so it can be better used to display information, at present the base tables defined are Contacts, Events, Participants, Contributions and Activities. These tables are linked in various ways so that you have a fairly flexible framework with which to build your queries from.

As well as the fixed tables that CiviCRM uses, this integration will also go through all your Custom Data Groups which are related to the 5 base tables above and automatically assign them. There's also the ability to create links with whatever text you like, that can link to either the usual CiviCRM Management Pages and functions, OR to a custom Drupal View as a Page, with the contact/event/etc ID tacked on the end. What this means is it should be quite feasible to build a front end for grabbing information that your users specifically need for your implementation of CiviCRM, without having to hack up the various CiviCRM Pages or touch a shred of PHP.

Not every single field of information that could be used has been implemented yet, for example things like Honorees and Recurring Payments are still on the todo list, but overall a fair amount of information can be pulled from the CiviCRM Database. While this stuff I'm doing is very much hobby work in between my real work, most fields can be added fairly simply using existing handlers so if one or two things are missing that you'd like for your implementation, or if something isn't working as it should let me know on the forums and I'll see if I can sort it out. A diagram of how the Views Tables are joined can be found on the wiki and the adjustments should be in the CiviCRM 2.2 alpha shortly.

James Rakich

Update: This code has now been committed to svn and will be part of the alpha 2 next week

( categories: )

Comments

I would like to help, but need some pointers to get started

If I want to assist in enabling more fields to be used in Views2 (eg. civievent max participants, and currently registered participants), where do i go for more info to get a clue?  I looked at the civicrm developer docs but do not see info about Views...

Not finding correct database?

I'm far from expert here, so I may be wrong, but it looks like the Views integration doesn't "understand" if Civi is using its own database. I get the following error when I try to create an event View in Drupal:

user warning: Table 'd6.civicrm_event' doesn't exist query: SELECT civicrm_event.id AS id, civicrm_event.title AS civicrm_event_title FROM civicrm_event civicrm_event LIMIT 0, 10 in...

d6 is my Drupal db - my Civi db is d6civi. Hope this helps... thanks for all the work you do!

Please use the forums for all support topics:

http://forum.civicrm.org/index.php/board,42.0.html

lobo

Use CiviCRM? Like CiviCRM? Then show your appreciation and donate to CiviCRM

Excellent addition. Thanks

Excellent addition. Thanks a lot for your work. I worked in the cost of making these Views additions into an upcoming project. Now we won't need to allocate as much time to that part. This seems to happen a lot: someone beats me to developing something new.

--
Dave Hansen-Lange
Web Developer
Advomatic LLC
http://advomatic.com
Hong Kong office

Re "whoever needs the data

Re "whoever needs the data with the right login credentials"

(How) does this relate to CiviCRM ACL's and/or Drupal OG or OG User Roles? Being able to integrate CiviCRM data into a Drupal site using Views sounds great. I need to be able to support advanced contact searches that obey group-based access control (if you belong to Group A, you can see fields XYZ of contacts in Group B). User should be able to log into Drupal, and have their OG membership honored by the corresponding CiviCRM group membership and ACL during a search. Have managed to get this to work with a custom Drupal module. Would love to be able to dispense with the custom module.

Drupal Views Access Control

Views can restrict who can use a view via Drupal Access Permissions and Drupal Roles. Therefore anything you can sync with Drupal's Roles using CiviCRM's sync modules, you can sync with Views to control your access. You set it up when you build the views in Site Building.

Relationships

Hello, James.

I'm currently working on adding Relationships table to Views 2, and already have some basic fields available. What is the best way to merge my code to your integration code?

Regards,
Danila

Suggestions

Good stuff Danila, just having a look at it, the relationships required to link up to civicrm_contact could be a bit tricky because you have to go through the table in BOTH directions, probably requiring multiple relationship handlers to be set up. Play around with it a bit and see how you go, I have an idea for it but haven't the time right now to chase it, on the weekend maybe if you have issues integrating it.

As well as that, rather than joining to relationship_type_id (which is just a type storage area), I'd recommend using the function CRM_Core_PseudoConstant::relationshipType() inside a handler you attach to civicrm_relationship -> relationship_type_id. It'll return an array you can use to convert your type_id into a plain text description. Use civicrm_handler_filter_activity_type.inc and civicrm_handler_field_activity_type.inc as inspiration, you'll just have to edit it a little to pull more from the array, two text fields instead of one.

Danila: Can you please put the right license on your file(s)

check: http://civicrm.org/licensing

and then create an issue (http://issue.civicrm.org/) and attach your change(s) as a patch to the trunk version. The new views code (from james) is at: http://svn.civicrm.org/civicrm/trunk/drupal/modules/views/

lobo

Use CiviCRM? Like CiviCRM? Then show your appreciation and donate to CiviCRM

Relationships - Views 2 Patch prepared

I have placed the patch to http://issues.civicrm.org/jira/browse/CRM-3995

Hope I specified licensing correctly.

I have tested patched code from views folder on 2.1.4, on a view which I need: aggregated list of companies where our alumni work with a number in brackets:

Company A (3)
Company B (20)

When one clicks on a company, a list of people working in it appears.

I have not yet tested if it is possible to link to several tables continuously - like "Show all contributions from people that work in Company A".

Regards,
Danila

This code is part of alpha3 ..

thanx for the contribution :)

lobo

Use CiviCRM? Like CiviCRM? Then show your appreciation and donate to CiviCRM