We use cookies to improve our services and provide a better experience. By continuing to use this site, you agree with our Cookies Policy.

More than 400 step-by-step articles to guide you through online project development.
HomeTutorialsCMS TutorialsDrupalDrupal Administration

How to Remove Search Form from Search Results Page

Sometimes the search form can be unnecessary or might look out of place and it would be great to remove it. However, it might be impossible to do this by editing Drupal settings. Therefore, it’s better to find a workaround for this issue either by using CSS or implementing custom made PHP script which removes search form.

Follow These Steps to Remove Search Form from Search Results Page

By doing it through CSS it might look quite tricky as you will need to find a correct block in the style file which defines the view of the search form. Also, it requires to have at least basic knowledge in CSS and it’s possible to make a complete mess in the website design by making a small mistake. You can simply use option “display:none” to hide the search form.

Another way to remove search form is to use custom made PHP script. An example of such script is provided below.

function theme_name_form($element) {
if (your_condition)
return '<form ' . $element['#action'] . ' accept-charset="UTF-8" method="' . $element['#method'] . '" id="' . $element['#id'] . '"' . drupal_attributes($element['#attributes']) . ">\n" . $element['#children'] . "\n</form>\n";
return '';

Simply put this code in the template file and make sure to replace “theme_name” with the actual name of the currently activated theme. This way you won’t need to spend time in finding the correct line to edit in CSS file. But in most cases, both methods should be working pretty easy to remove search form from search results page.

Rate this Tutorial:
No CommentsLeave a Comment

Other (195)

Popular Keywords