Many modules (most notably commerce) provide default views to define much of their interface but hard code the view that is used to render that interface. That means that modifications to these views cannot easily be deployed in code or otherwise managed via tools like features.

This module allows modules to implement a hook (`hook_default_views_overrider_views_to_override`) to announce views that need to be overridden and what view to override them with. There is currently no interface, it is an API module only. With a view overridden you will not be able to edit the original view because you will be redirected to the new view. This is to prevent users from accidentally investing time in making changes to a view that is no longer visible anywhere on the site.

Usage

  1. Download and install this module `drush dl views_default_view_override`.
  2. Enable the module `drush en views_default_view_override`.
  3. Go to the view interface you want to change at `admin/structure/views` and clone the view you want to override.
  4. Create a custom module and implement `hook_views_default_view_override_views_to_override()`, return an array with keys for the original view to override and corresponding values of the view to replace it with. See below for an example of the hook.
  /**
   * Implements hook_views_default_view_override_views_to_override().
   */
  function my_module_views_default_view_override_views_to_override() {
    return array(
      // Override the default commerce_cart_block view with the one provided by my_module.
      'commerce_cart_block' => 'my_module_commerce_cart_block_override',
    );
  }

Note on upgrading to version 2.0 - the name of the module did not used to match the name of the drupal.org project. This was massively confusing and it has been corrected but means the name of the hook has changed.

Supporting organizations: 
Provided work time to contribute this project back.

Project Information

Downloads