Views 3 Relationship Handler I am trying to write a relationship handler for Views 3 in Drupal 7, but am failing even to begin.

Basically, I have a bunch of nodes of various types all with the same field attached to them. This field is a reference field linking off to a Civicrm contact - but that's not important, as essentially these fields just contain integers.

Now, let's say I have a node of content type 'story', and its reference field contains the integer, oh, let's say 55. In addition, there are nodes of content type 'news' which also contain the reference ID 55.

I want to build a block view, that sits on the story page, that reads in the node's nid as its argument, and then through a relationship it discovers all other nodes that contain the same reference integer as itself.

(In my head, the sql looks something like: SELECT n.nid FROM node n INNER JOIN node n2 ON n.reference = n2.reference [Assuming, for the sake of simplicity, the field data is kept in the node table]).

How do I create a Views handler that caters for this relationship? The only documentation I can find is the views api, which is for version 2 and not 3, and besides is utterly unhelpful. Reading various module's views handlers is not helping either, and views tutorials on the web are almost non-existent.
Are you really sure you need a relationship handler for this?

In general the default relationship handler is already quite flexible because it uses the default join class which is really powerful.

There are some use cases for relationship handlers, for example the relation module, but this module does some vodoo stuff.

So back to the problem. It might be enought if you define 'relationship' with the right field and base field.

PS: There is a big reason why there is no documentation about api=3 because the difference to api=2 isn't big at all.

Here is an example how to define a relationship.

  $data['node_revision']['vid'] = array(
    'relationship' =&gt; array(
      'handler' =&gt; 'views_handler_relationship',
      'base' =&gt; 'node',
      'base field' =&gt; 'nid',
      'title' =&gt; t('Content'),
      'label' =&gt; t('Get the actual content from a content revision.'),
    ),
  );