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

7

5

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 ;)

Singleaction answered 9/8, 2010 at 14:57 Comment(2)
does the search block show you anything?Ocular
if you mean changing $search_box with $search_block, no it doesn't change anything...Singleaction
M
15

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.

Moleskin answered 9/8, 2010 at 18:55 Comment(0)
R
4

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.

Rocha answered 26/5, 2012 at 5:48 Comment(0)
V
2

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

Voidance answered 9/9, 2010 at 17:21 Comment(0)
C
2

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; ?>
Casabonne answered 21/3, 2011 at 10:55 Comment(0)
T
1

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.

Tourneur answered 11/8, 2010 at 17:10 Comment(1)
I already had all the features I needed, and it didn't show up... @bkildow's solution was the oneSingleaction
T
1

Drupal 7:

Modules > Search > Permissions > Use search > select for: ANONYMOUS USER and AUTHENTICATED USER.

Turbidimeter answered 1/4, 2012 at 15:52 Comment(1)
Hello and welcome to StackOverflow! Direct path for this is Administer > People > Permissions :)Clubby
I
0
//clear target element - optional
$('[data-id=1381]').html('');
//move search form
$('#search-block-form').appendTo('[data-id=1381]');
Inquire answered 21/2, 2015 at 22:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.