How do I check if the page I'm viewing is a Views page? I want the breadcrumbs to be hidden if the user is viewing the view page I made, which I named "Products."

I am using Drupal 7 and Views 7.x-3.0-beta3.


5 Answers 5


Following Jeremy French reply, I must say that you can do it like this :

if(function_exists('views_get_page_view') && views_get_page_view()){...YOUR CODE HERE...}

Taken from here:

views_get_page_view() finds out what, if any, page view is currently in use. If it returns NULL, then the current page is not a views' page.


Quick and dirty would be to use CSS - take the class Drupal assigns to the views page and then do something like:

.drupal-views-page-class .breadcrumb-container {display:none}

Of course, you need to use your actual class names.

  • 1
    Hehe, you're right. Quick and dirty. I'll consider this if all else fails. Thanks @Mike this one made me laugh. :-)
    – enchance
    Jun 26, 2011 at 13:32
  • Very, very dirty.
    – leymannx
    Jul 29, 2014 at 14:31

For d6 site the following trick might work.

 * Implementation of hook_views_pre_render()
function mymodule_views_pre_render($view) {
  if ($view->name === 'my_products_view') {
  • 1
    Is there a method which uses the standard way of checking through <?php if(condition) : ?> This gets printed <?php endif; ?>? That way I can just check if it's a Views page and not print the breadcrumbs.
    – enchance
    Jun 26, 2011 at 13:31
  • @enchance - Depends on where exactly you want to check this. Maybe <?php if(isset($view->name)) : ?>This gets printed<?php endif; ?> works for you.
    – leymannx
    Jul 29, 2014 at 14:30

I have some code that shouldn't be displayed on certain content types. There's an easy approach for this:

<?php if (!empty($node) && (($node->type != 'article') && ($node->type != 'webform'))): ?>
     This content is shown everywhere except on articles and webforms. Yet it doesn't show up on views pages either while it should.
<?php endif; ?>

But it occured to me that it would hide this content for views pages as well (because the node is empty there: (!empty($node)).

My workaround for this is:

    if(function_exists('views_get_page_view') && views_get_page_view()){
      $viewspage = "yes";
<?php if (((!empty($node)) || (!empty($viewspage))) && (($node->type != 'article') && ($node->type != 'webform'))): ?>
     This content is shown everywhere except on articles and webforms. It does show up on the other content types ànd the views pages. So it's ok.
<?php endif; ?>

This is working, but I wondered if this is the right approach. It looks a bit like a kindergarten-method.


For me the following works in hook_preprocess_page() and in hook_preprocess_html() as well:

function MYMODULE_preprocess_page(&$vars) {
  $view = (array)views_get_page_view();
  if (!empty($view)) {
    // do stuff

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.