Mirroring Contacts As Nodes

How Mirroring Works

The core tool for mirroring is the civinode_contact node type, which is a Drupal node that stores a CiviCRM contact_id that points to a CiviCRM contact. Right now, this is the only required information that the node needs to store on the Drupal side. I use hook_load to marshall data from CiviCRM for that contact_id into the Drupal node object. Right now, I've only implemented the "read" piece of mirroring, but when I do implement editing and creation of CiviCRM contacts from within Drupal, I will do it by using hook_insert and hook_update to write the data back into CiviCRM.

It's worth noting that CiviCRM already does mirroring into Drupal, but between CiviCRM contacts and Drupal user objects. I don't change this at all, and in fact, even depend upon it. Like the machinery in CiviNode, Drupal stores CiviCRM-type contact information in CiviCRM, and when new Drupal users are created, either the matching contact in CiviCRM is used (matching is typically done on the email address), or a new CiviCRM contact is created. This process is very handy, since it makes it easy to "acquire" user information from Drupal web applications, but manage and track this information in CiviCRM. Often, this is exactly what you want to do, and I see no reason to change this.

Why Mirror Nodes?

So why mirror nodes at all?

First, because very often, you want to store information about contacts that are not users of your web site, and who never will be users of your web site. In these cases, you may want to do things that are difficult or impossible to do in CiviCRM, such as use Drupal taxonomy, or in some way or the other treat a contact as a "project" -- perhaps you are trying to do some group of activities to turn a contact into a donor, or you are managing press people and want to make sure you are coordinating your activities with different reporters. Drupal makes it relatively easy to do this if your contacts are managed as nodes, and fairly difficult if they are not.

But if managing this information as nodes does not make sense to your application, I am trying to write CiviNode in such a way that it does not force you to do so. If you want to look at your contacts as Drupal users, it lets you do it. In many cases, CCK support is what you really want to use. But you're free to use node mirroring if you choose.