Drupal - How to determine if the current page is a search results page?

If you're trying to determine from a module then you can check if the page is the search results page via the path arguments using the arg() function.

if (arg(0) == 'search') {
  TRUE
}
else {
  FALSE
}

From a theming point of view you could simply use

<?php if ($search_results) : ?>
    <!-- Do this on search results pages -->
<?php endif; ?>

$search_results should only return true if you are on a search results page.

If you're looking into styling the results themselves you might want to look into search-result.tpl.php

Tags:

Search

7