0

Let’s say I have a Drupal content type of Widget that has an integer field “widget_id”. I have a custom MySQL table called “new_widgets” with the fields “id” and “widget_name”.

I’m trying to create a view that lists all entries in my new_widgets table and shows which of those Widgets have related Widget nodes. Not all new_widgets have nodes. So the results would be: widget_id, widget_name, nid

Query would be something like this:

SELECT nw.widget_id, nw.widget_name, entity_id as nid FROM {new_widgets} nw LEFT JOIN {node__field_widget_id} wid ON nw.widget_id = wid.field_widget_id_value

Don’t think I need {node_field_data} since I’m getting the node id from the entity_id field.

I’ve been trying to figure out how to set it up using hook_views_data() but can’t get it to work. Or do I need to use hook_views_data_alter()?

Your Answer

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

Browse other questions tagged or ask your own question.