Skip to main content

Overriding Admin Views in Drupal 7

Jul 07 '17

The Admin Views module uses Features to provide Views-based replacements for the administration pages that are provided by Drupal core. This is very handy when you want to modify these pages, such as adding custom columns or search options.

But when it comes to deploying these changes, things get a little weird. Normally you'd simply export a custom View using Features and commit the exported code to your VCS. When using the Admin Views module, you'll need to take a couple extra steps.

Because the Views provided by Admin Views are themselves simply exported Features, and each Feature can only be provided by a single Features module, you
can't simply re-export them without overriding the code in the contrib module (which we definitely don't want to do).

Instead, first use the "clone" operation in Views to create an exact copy of the Admin Views view(s) that you want to customize.  Make your modifications, then export these clones to a custom module of your choice.

Finally, implement hook_views_default_views_alter() and disable the View(s) that you have replaced.  In this example I overrode the ones at admin/content and admin/content/file:

 * Implements hook_views_default_views_alter().
function mymodule_views_views_default_views_alter(&$views) {
  $views_to_disable = array('admin_views_file', 'admin_views_node');
  foreach ($views_to_disable as $view) {

To keep things nice and clean, I add this code to the module I created when exporting my customized Views. That's all there is to it! Now you have a deployment-friendly custom module with all your customizations.

Read more about: