I haven't used Views much before but it feels like I should be so I'm getting stuck in...

I think I'm missing something obvious here but how would I go about creating a view that 'mixes' several different entity types?

I have a custom field type attached to nodes, users, and also to user profiles provided by the Profile2 module. The field contains lat/long data (I know OpenLayers etc. provide this functionality, the field type was built as an exercise).

How can I create a view that contains all of the different entities that have this lat/long field associated with them? I'm basically after a simple table with 'Entity Title', 'Lat' and 'Long' as columns.

All of the different entity types are separated when I create a view (Content, Users & Profile) and I can't find a way to group them together so to speak.

Is this possible with Views or is not quite there yet with regard to entities?


1 Answer 1


Views uses a term it calls base table translated into SQL it is the table used for the initial query

SELECT something FROM {base_table};

The thing is that what you want to do is a bit atypical, instead of doing

SELECT something, field_item FROM {entity} LEFT JOIN {field};

You want to do

SELECT something, field_item FROM {field} LEFT JOIN {entity};

In order to do this you need to use the field you are after as the base table. By default this is not possible, but it's not much work required in order to do it. What you need to do, is to use hook_views_data or hook_views_data_alter and add the data for the field table and make it selectable as base table displayed when you create a view.

There's a lot of doc on how to do this (the Views doc), and I have written this in one or more answers here. So I won't bother explaining how to do this.

  • 3
    Thanks - nice answer. Would love to see links to the other places you've addressed how to do this. Commented Jun 9, 2013 at 3:04
  • can anybody explain plz how to do this?
    – Umair
    Commented Sep 30, 2016 at 16:38
  • Funny, because if I enter the terms "user:190 base_table" into the search field I only get one other result and it doesn't contain the answer. googletorp is a prolific user on here with many accepted answers - perhaps he answered this question elsewhere and mis-remembered that it was on this site. In any case I'd love to see a D8 answer to this question.
    – griz
    Commented Apr 7 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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