1

I'm trying to find a way to check the view name of the current page.

$views_page = views_get_page_view();
if (is_object($views_page)) {
    //get the view name
}

I haven't found any function that gives that information. Any suggestions?

3 Answers 3

6

views_get_page_view() returns a View object. The name should be stored in $views_page->name.

1

Once you have a view object, call view::get_title().

0

Use below code in your module file


function MYMODULE_views_api() {
  return array(
    'api' => 2,
    // might not need the line below, but in any case, the last arg is the name of your module
    'path' => drupal_get_path('module', 'MYMODULE'),
  );
}

Use below code in your MYMODULE.views.inc

function MYMODULE_views_query_alter(&$view, &$query) {
   echo $view->name; exit;
 }


Relpace MYMODULE with your module name.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.