Skip to content

Instantly share code, notes, and snippets.

@yanniboi
Last active January 20, 2016 17:16
Show Gist options
  • Save yanniboi/cb7c621089cf97e2f4d5 to your computer and use it in GitHub Desktop.
Save yanniboi/cb7c621089cf97e2f4d5 to your computer and use it in GitHub Desktop.
Drupal 7 views alter
<?php
/**
* @file
* Module file for cmi_test to register module with views.
*/
/**
* Implements hook_views_api().
*/
function cmi_test_views_api() {
return array(
'api' => 3,
);
}
<?php
/**
* @file
* Views default configuration file to add and alter views exports.
*/
/**
* Implements hook_views_default_views_alter().
*/
function cmi_test_views_default_views_alter(&$views) {
if (isset($views['comments_recent'])) {
// Add an exposed filter for comment approval.
$handler =& $views['comments_recent']->display['page']->handler;
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'comment';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = '1';
$handler->display->display_options['filters']['status']['exposed'] = TRUE;
$handler->display->display_options['filters']['status']['expose']['operator_id'] = '';
$handler->display->display_options['filters']['status']['expose']['label'] = 'Approved comment';
$handler->display->display_options['filters']['status']['expose']['operator'] = 'status_op';
$handler->display->display_options['filters']['status']['expose']['identifier'] = 'status';
$handler->display->display_options['filters']['status']['expose']['required'] = TRUE;
$handler->display->display_options['filters']['status']['expose']['remember_roles'] = array(
2 => '2',
1 => 0,
3 => 0,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment