2

Two content types: subscriptions and sites. Each site belongs to a subscription. I use the UUID module, since subscriptions and sites are synced from websites elsewhere. Each site has a field_subscription_uuid field to identify the subscription it belongs to. There can be multiple sites on each subscription.

I want to make a view that lists sites alongside some of the data from their subscription. I thought I would use the Equi Join module to relate a site's field_subscription_uuid to a subscription's uuid. However, Equi Join only lists custom fields (and body), not UUID.

Although I could create a new custom field for subscriptions and sync its own UUID to that field to make it visible to Equi Join, I would rather not because it would be redundant (since the UUID is already a column in the node table).

So I think I have to write a views relationship handler in order to bring a node's uuid into the scope of Views relationships, but I don't know where to start and the API documentation has only confused me more.

How can use a specific node type's UUID in a views relationship without storing the UUID in a custom field?

1

I figured out how to do this. It doesn't require a custom relationship handler. In MYMODULE.views.inc:

/**
 * Implements hook_views_data_alter()
 */
function MYMODULE_views_data_alter(&$data) {
  // Add a relationship between the field_subscription_uuid field and node UUIDs
  $data['field_data_field_subscription_uuid']['field_subscription_uuid_value']['relationship'] = array(
    'title' => t('UUID'),
    'help' => t('Relationship for field_subscription_uuid to node UUID.'),
    'handler' => 'views_handler_relationship',
    'base' => 'node',
    'base field' => 'uuid',
    'label' => t('UUID'),
  );
}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.