I have a table that contains the columns nid and uid. In hook_views_data, I only see an option for a join to contain one column. I would like the join condition LEFT JOIN my_table ON node.nid = my_table.nid AND node.uid = my_table.uid.

Is this possible? My first thoughts are somehow overriding the views_join handle, though I don't know how to do this.

Thanks!

Comments

dawehner’s picture

I'm not sure whether this is a good way.

You could extend the views_join class, and extend it so that you can add two join criterias(or multiple).

Then you create a new instance of your class, and let it use as views_join object.

venkatd’s picture

I have successfully extended the views_join class. However, I can't get the handler to be automatically included. I have implemented the following hook_views_handlers but it doesn't seem to work.


/**
 * Implementation of hook_views_handlers()
 */
function uc_node_purchases_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'uc_node_purchases') . '/handlers',
    ),
    'handlers' => array(
      'views_handler_filter_boolean_null_operator' => array(
        'parent' => 'views_handler_filter_boolean_operator',
      ),
      'views_join_multiple' => array(
        'parent' => 'views_join',
      ),
    ),
  );
}

The view_handler_filter_boolean_null_operator is included as expected but views_join_multiple isn't. If I manually include it in hook_init of my module then it works, but that feels like a hack. Any idea on how to do it the right way?

Thanks!

Alun’s picture

Hello, I know this is an old issue, but it makes more sense to bump this one, rather than start a new one..
I am getting the same problem as outlined by venkatd.
I have extended the views_join class in the same way as outlined above. The name of my handler is 'leaguesite_join_relation'

I then created a file called 'leaguesite_join_relation.inc' in the same folder and extended views_join in that file. However, it is not getting called.
Am I declaring the handler correctly or is it an issue in Views?
If its my fault, I promise to write up some documentation on how to do this for others, as a way of repaying for your time.
Thanks!
Alun

Alun’s picture

Version: 6.x-2.6 » 6.x-2.8
Alun’s picture

Status: Active » Fixed

Just found this comment from merlin, I'll follow these instructions.
http://drupal.org/node/540128#comment-1889104

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.