function tripal_enable_view

2.x tripal_enable_view($view_name, $redirect_link = FALSE)

Programatically enable view

This should be used in a hook_menu definition as the callback to provide a link to enable the view (first example). It can also be called directly if needed (second example).

// Create a URL that when the user navigates there, a given view will be enabled.
// You will still need to provide a link to this menu item somewhere appropriate (ie: an admin landing page).
function mymodule_menu() {
 $items = array();

 // Create one of these for each of your default views
 $items['admin/tripal/<PATH-TO-YOUR-ADMIN-SECTION>/views/<VIEW-MACHINE-NAME>/enable'] = array(
   'title' => 'Enable <VIEW-HUMAN-READABLE-NAME>',
   'page callback' => 'tripal_enable_view',
   'page arguments' => array('<VIEW-MACHINE-NAME>', '<PATH-TO-REDIRECT-TO-AFTERWARDS>'),
   'access arguments' => array('<YOUR-PERMISSION-KEY>'),
   'type' => MENU_CALLBACK,

 return $items;

// Call this function directly to disable a view
// The example shows enabling your own default view when your module is enabled.
// This might be useful if you disable your view when your module is disabled.
function mymodule_enable() {

 $view_name = '<VIEW-MACHINE-NAME>';



$view_name: The machine-name of the view to be enabled

$redirect_link: The path to redirect to. FALSE if no redirect needed

Related topics

1 call to tripal_enable_view()
15 string references to 'tripal_enable_view'
tripal_bulk_loader_menu in tripal_bulk_loader/tripal_bulk_loader.module
Implements hook_menu().
tripal_core_menu in tripal_core/tripal_core.module
Implements hook_menu(). Defines all menu items needed by Tripal Core
tripal_cv_menu in tripal_cv/tripal_cv.module
Implements hook_menu(). Registers all menu items associated with this module
tripal_db_menu in tripal_db/tripal_db.module
Implements hook_menu().
tripal_featuremap_menu in tripal_featuremap/tripal_featuremap.module
Implements hook_menu().

... See full list


tripal_views/api/, line 223
API functions for Tripal Views Integration


function tripal_enable_view($view_name, $redirect_link = FALSE) {

  $status = variable_get('views_defaults', array());
  if (isset($status[$view_name])) {
    $status[$view_name] = FALSE;
    variable_set('views_defaults', $status);
    drupal_set_message("Successfully Enabled $view_name");
  else {
    drupal_set_message("Unable to find a view by the name of '$view_name'. Unable to enable this view.", 'error');
  if ($redirect_link) {