Changing the default search box

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
trista13's picture

I'm working with the MAYO theme (http://drupal.org/project/mayo) and it has a nice feature where you can turn on and off a search box in the header through Administrator-Themes-Settings. I'd like to use this search box, but with a different search box (one that searches our library catalog). So, basically, I'm looking for a place to stick the HTML code in the MAYO theme so that that search box becomes my search box. I've looked through the CSS and other files in the theme, but all I see is the layout of the search box, not the actual information for the search box. I'm wondering if this is even possible to do because I'm thinking this theme is using the search that is in Drupal core and so therefore I cannot change the settings through the theme. I suppose I could add a block to the header and then put my search box in that block... I'll keep messing around in there, but if anyone has any advice or has similarly tweaked a theme, please let me know where you made the changes (I do have a basic knowledge of CSS and HTML, but not php).

Thanks!

Comments

Blocks

scottrouse's picture

If you're putting in your own HTML form which returns the search results, you have a couple of options:

  1. Recode Drupal's core search to search something other than the Drupal content
  2. Hide Drupal's core search (and/or turn off the Search module altogether) and insert a custom form in a block

It's probably obvious that the second option is the most desirable (easiest). If you have custom search code, put that in a Block and place the block in your theme where you'd like it.

Yeah, I'm going to have to do

trista13's picture

Yeah, I'm going to have to do some research on adding a block... good thing it can wait!

We're just using an iframe

xmacex's picture

We're building a website for our consortia, and since it will be kind of simple and not too content will be there and it will be kind of a portal for now, we'll just disable the real Drupal searchbox and have a block, into which our OPAC search-thingie has been iframed into. I know iframes are totally evil™, but at this time we think it's ok the user jumps to the OPAC to look at the search results.

In the longer run we have a bit more eloquent plans. Namely we're planning building a Drupal module, that will fetch XML over an API from the real OPAC (ExLibris Primo) and parse it to a cover-image carousel, possibly using Feeds or somesuch. But until that, an iframe in a block should be sufficient.

I looked at this theme and

highermath's picture

I looked at this theme and was not wild about the way it was built, but that said, it wouldn't be hard to change the searchbox to a block.

To add a theme region called "Searchbox", open page.tpl.php and change

<?php if (theme_get_setting('header_searchbox')) { ?>
  <div id="header-searchbox" style="<?php echo $searchbox_style; ?>">
  <?php print render(drupal_get_form('search_block_form')); ?>
  </div>
<?php } ?>

to:
<?php if (theme_get_setting('header_searchbox')) { ?>
  <div id="header-searchbox" style="<?php echo $searchbox_style; ?>">
  <?php print $searchbox; ?>
  </div>
<?php } ?>

Or if you don't want to use Mayo's theme settings system for this -- say if you want to use adjustisearch or something where the theming for the core search won't translate well:
<?php if ($searchbox): ?>
  <div id="searchbox">
    <?php print $searchbox; ?>
  </div><!-- /searchbox -->
<?php endif; ?>

Close and save that and open mayo.info and add the line:
regions[searchbox] = Searchbox

This will likely require some tweaking on the css side.

Thanks for the tip... I'm

trista13's picture

Thanks for the tip... I'm pretty new to Drupal and haven't messed around much with changing themes. When I put the code you suggested into the theme and move my search widget block to the new region, it just disappears. Not sure why...

One thing that you should do

highermath's picture

One thing that you should do for sure is clear the theme cache. The easiest ways to do this are with the Admin Menu, the Devel module, or with drush.

If you used the second, simpler, approach, you should check the source code and see if there is a searchbox div and, if so, if there is anything in it. If there is, then you need to theme it into the correct position. If not, then I don't know and would probably need more insight to tell.

Yeah, I kind of figured that

trista13's picture

Yeah, I kind of figured that was the issue. I've been playing around with it this weekend and I think I just need to redo the entire search box that is already in the theme. I don't know much about configuring a theme and there is a lot of stuff in there with the search box so it's a bit overwhelming. I really appreciate you getting me this far and I will continue to read up and look into changing the theme to suit my needs. I have the search box I want in a sidebar right now, so it's not essential to move it to the header.
Thanks again!

Libraries

Group organizers

Group categories

Resources

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: