Can't get the search box to show up in custom theme

16,702

Solution 1

From: http://drupal.org/handbook/modules/search

If both the search module and the menu module are enabled, from the menus page (administer >> menus) you can enable on the Navigation Menu the item Search. The option to show this menu item may be disabled by default, but you can enable it. (And you can rename "Search" to whatever you wish.)

You can also place a link to Search among your site's primary and secondary links, or on any other menu as well. (Click "add menu item," and when you fill in the "path" field on the dialogue page just enter "search.")

On your blocks page (administer >> site building >> blocks in Drupal 6, and administer >> structure >> blocks in Drupal 7) there's also a Search form you can enable, and you can choose where you want it to display.

On your permissions page (administer >> user management >> permissions in Drupal 6, or People >> Permissions in Drupal 7) you can decide who can do searches and who can administer the search settings. By default, anonymous users cannot perform searches.

A technical note: To use the search module the database user needs the create temporary table permission. If you seem not to have it, ask your systems administrator to make sure it's granted to you.

Solution 2

Drupal 7 - If the "Search" block, or any other block, is 'enabled' in the "Dashboard", it no longer is available on the 'Stucture' > 'Blocks' block list page.

Solution 3

Go to administer>>themes and configure your custom theme then check Search box.

Solution 4

if you are using drupal 7 please use the following

<?php if($page['search']): ?>
    <!--start search-->
    <div id="search">
      <?php print render($page['search']); ?>
    </div>
    <!--end search-->
  <?php endif; ?>

Solution 5

I had this same problem. In my case I found that in my custom theme .info file I was using some features like so:

features[] = MyFeature

As soon as you add one feature, it overrides the display of all the built in features such as search, etc, and so they don't show up on the configuration page of your theme. What happened with me was that the search box had been disabled before I started my custom theme, but because I could not see it on my config page, I could not re-enable it.

I finally discovered that I could click the "reset to default" button and then my theme inherited the search settings from the global defaults from then on.

Share:
16,702
3rgo
Author by

3rgo

Computer Science Engineer, specialized in Web development. Work : 2011-2016: Intranet tools development for Airbus France (Single page JS apps, with a PHP5+Symfony 2 REST API ; custom made Ruby CI/CD pipeline). 2016-2018: Project Manager/CTO for Decasoft 2019+: Freelance web developer (Symfony, Laravel, ReactJS) and Trainer (PHP, OOP, Algorithmics, JS) Tech Stack: PHP 5 to 8 Symfony, Laravel Laravel Livewire PHPUnit Javascript ReactJS AlpineJS MeteorJS (in progress) jQuery, Underscore/Lodash, MomentJS, D3.js, Leaflet MySQL, PostgreSQL, mongoDB (in progress) Bootstrap, MaterialUI, TailwindCSS Jenkins, Git Apache, NGINX Windows, Ubuntu, macOS Python, Bash

Updated on July 31, 2022

Comments

  • 3rgo
    3rgo over 1 year

    I'm trying to make a custom theme for a drupal blog, and I want the search box to appear in the header. To do that, I've put the following code in the page.tpl.php template file :*

    <?php if ($search_box): ?>
        <div id="search-box"><?php print $search_box; ?></div>
    <?php else: ?>
        <h2>Pas de search box</h2>
    <?php endif; ?>
    

    But the damn thing won't show up. I did some research on google, and checked the Search module on admin/build/modules and admin/build/themes/settings/mytheme, and added the search form to the header in admin/build/block/list/mytheme. Did I miss something, or did I do something wrong ? Because it's still not working, and beginning to piss me off...

    Thanks.
    Regards from France ;)