Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Sep 2010 at 11:43 UTC
Updated:
22 Sep 2010 at 13:10 UTC
Hi all,
I'm trying to get a relationship to work using 6.x-3.x-dev (2010-Aug-02) but when I save the view I always get a "Broken/missing handler: sometable > ruid" and this relationship is missing until I flush the views cache.
So here is how my code looks like. First my table schema containing a node(nid) - user(ruid) relationship:
$schema['sometable'] = array(
'fields' => array(
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'ruid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
'rnid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
),
'primary key' => array('nid', 'ruid'),
);
And here is my hook_views_data and the user relationship:
function mymodule_views_data() {
$data = array();
$data['sometable']['table'] = array(
'group' => t('Reviews'),
'title' => t('Reviews'),
'help' => t('User-node relationship.'),
);
$data['sometable']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'nid',
),
'users' => array(
'left_field' => 'uid',
'field' => 'ruid',
),
);
$data['sometable']['ruid'] = array(
'title' => t('Uid'),
'help' => t('User id.'),
'field' => array(
'handler' => 'views_handler_field',
),
'filter' => array(
'handler' => 'views_handler_filter',
),
'relationship' => array(
'title' => t('Uid'),
'label' => t('Reviewer Uid'),
'base' => 'users',
'base field' => 'uid',
'skip base' => array('users', 'sometable'),
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
$data['sometable']['nid'] = array(
'title' => t('Nid'),
'help' => t('Node id.'),
'field' => array(
'handler' => 'views_handler_field',
),
'filter' => array(
'handler' => 'views_handler_filter',
),
'sort' => array(
'handler' => 'views_handler_sort',
),
);
return $data;
}
So what am I missing here?
Would be great if someone could help me.
Thanks,
sb
Comments
Comment #1
stephanbauer commentedHi again,
I still can't get it working, I tried with a table base but then it completely stopped working (and I don't want to lose my primary keys).
Could someone give me a hint?
(using Views 6.x-3.x-dev 2010-Aug-18)
Thanks,
sb
Comment #2
dawehnerYou miss
in the relationship defininition :)
Comment #3
stephanbauer commentedHi,
sometimes I'm really blind, but I thought it defaults to 'views_handler_relationship' if not set?
Well, it work now, I guess... :)
Thanks a lot!
sb
Comment #4
dagmar