Answers for "drupal 8 hook_view_"

1

drupal 7 hook_views_pre_view

function hook_views_pre_view(&$view, &$display_id, &$args) {

  // Change the display if the acting user has 'administer site configuration'
  // permission, to display something radically different.
  // (Note that this is not necessarily the best way to solve that task. Feel
  // free to contribute another example!)
  if ($view->name == 'my_special_view' && user_access('administer site configuration') && $display_id == 'public_display') {
    $view
      ->set_display('private_display');
  }
}
Posted by: Guest on March-25-2021

Browse Popular Code Answers by Language