function hook_views_default_views_alter

You are here

7 views.api.php hook_views_default_views_alter(&$views)
6 docs.php hook_views_default_views_alter(&$views)

Alter default views defined by other modules.

This hook is called right before all default views are cached to the database. It takes a keyed array of views by reference.

Example usage to add a field to a view:

  $handler =& $view->display['DISPLAY_ID']->handler;
  // Add the user name field to the view.
  $handler->display->display_options['fields']['name']['id'] = 'name';
  $handler->display->display_options['fields']['name']['table'] = 'users';
  $handler->display->display_options['fields']['name']['field'] = 'name';
  $handler->display->display_options['fields']['name']['label'] = 'Author';
  $handler->display->display_options['fields']['name']['link_to_user'] = 1;

Related topics

File

./views.api.php, line 849
Describe hooks provided by the Views module.

Code

function hook_views_default_views_alter(&$views) {
  if (isset($views['taxonomy_term'])) {
    $views['taxonomy_term']->display['default']->display_options['title'] = 'Categories';
  }
}

Comments

This hook DOES NOT need to be in MODULENAME.views_default.inc as hook_views_default_views().

Another example:

<?php
function mymodule_views_default_views_alter(&$views) {
 
$handler =& $views['myview']->display['default']->handler;
 
// now modify view
}
?>

After Clear the cache .Revert the views :P