I would like to know how I may use a database field from a custom module to build queries on.

By default, using content view starts off querying from the "node" table. I would love to have the Views module to query from my own custom table.

I have tried using hook_views_data() and set a base table, but it all came to nought so far.

1 Answer 1


Give this module a shot - Views Expose Tables

Exposes Drupal DB tables to Views

This is a simple module which does one thing: provides an admin page for site-builders to choose which tables in a site's Drupal DB to expose to Views.

The module then loads all the fields for each chosen table and detects the data type of the field and sets appropriate views field, sort, filter, and argument filters (for example numeric, string, date, or "default").

It also looks for a primary key of the table and if one is found it sets it as the base field for a views base table and makes the table accessible to views.

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.