Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.3
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Mar 2009 at 09:00 UTC
Updated:
9 Apr 2009 at 21:20 UTC
In hook_views_tables, I used the 'extra' field to make sure that when my table was used in a view,it ony used records which matched the current group. i.e.:
$tables['og_users_roles'] = array(
'name' => 'og_users_roles',
'provider' => 'internal', // won't show up in external list.
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'uid'
),
'right' => array(
'field' => 'uid'
),
'extra' => array(
'gid' => '***CURRENT_GID***'
),
),
How do I implement this using hook_views_data()?:
$data['og_users_roles']['table']['group'] = t('OGUR Groups');
$data['og_users_roles']['table']['join'] = array(
'node' => array(
'left_field' => 'nid',
'field' => 'gid',
),
'users' => array(
'left_field' => 'uid',
'field' => 'uid',
),
'role' => array(
'left_field' => 'rid',
'field' => 'rid',
),
);
I've been searching for an example, but so far no luck. Thanks for any info anyone can provide.
Comments
Comment #1
somebodysysop commentedAny suggestions?
Comment #2
somebodysysop commentedWell, just for the purposes of documentation, I resolved the issue in another way. I created a filter:
actually, lifted it from the OG module.
When I add this filter to my view, it makes sure that the table is only showing records related to the current view.
Would still like to know the answer to my original question, if anyone ever gets around to it.
Comment #3
cdale commentedThe views Advanced Help documentation has good details on how to achieve this. But you probably want something like the following:
One thing I would love to know myself is how to use the table alias for the left table, instead of the actual table name, but from looking at the code, I can't see anyway that this might be possible.
Comment #4
somebodysysop commentedYes, thank you. This is exactly what I was looking for.