function tripal_enable_view

2.x tripal_views.api.inc tripal_enable_view($view_name, $redirect_link = FALSE)
3.x tripal_chado_views.api.inc 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>';
tripal_enable_view($view_name);

 }

Parameters

$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()
16 string references to 'tripal_enable_view'
tripal_bulk_loader_menu in tripal_bulk_loader/tripal_bulk_loader.module
Implements hook_menu().
tripal_chado_menu in tripal_chado/tripal_chado.module
Implements hook_menu().
tripal_chado_views_admin_enable_view in tripal_chado_views/api/tripal_chado_views.DEPRECATED.inc
tripal_chado_views_menu in tripal_chado_views/tripal_chado_views.module
Implements hook_menu(). This hook provides details about new menu items added by this module
tripal_cv_menu in legacy/tripal_cv/tripal_cv.module
Implements hook_menu(). Registers all menu items associated with this module

... See full list

File

tripal_chado_views/api/tripal_chado_views.api.inc, line 65
Provides API functions that support direct integration of Chado tables with Drupal Views.

Code

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.", 'notice');
  }
  if ($redirect_link) {
    drupal_goto($redirect_link);
  }
}