Where is all the config for Views stored? I am working on a Drupal site with a very large number of Views. What's the easiest way to find "All the Views which have a Relation of a certain type", or "All the Views which output a specific field?"

It would be nice to do this with some SQL but I'm stumped as to how.


It's stored in the views_display table, as a serialised PHP string. So unfortunately direct querying isn't really feasible.

The best approach is to load each View object in turn (in PHP), and apply your filter logic there.

The views_ui_field_list() function is a good example of what's required. Incidentally that's the callback for a page that already exists in the admin which should help you find All the Views which output a specific field. It's at /admin/reports/fields/views-fields.

| improve this answer | |

Just expanding a bit on @Clive's answer. Load all views, iterate through them and check what you need.

Views has a function that will help, views_get_all_views(), https://cgit.drupalcode.org/views/tree/views.module#n1536

From there, you can go through them and get what you need.


$views_list = views_get_all_views(); foreach ($views_list as $view) { //Logic operating on the $view object }

This will probably be useful as well, https://api.drupal.org/api/views/includes!view.inc/class/view/7.x-3.x

| improve this answer | |

Your Answer

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

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