Hi,
Zen provides a search box that can be enabled or disabled.
In Drupal bock configuration, it's possible to add a different search box to a block.
Why two search boxes?
And how to put zen's search box in a different block than navbar?

Comments

crutch’s picture

I moved the theme search code to the header area by moving the snippet of code that displays the theme search box and putting in the zone I wanted it and then specifically positioned with CSS.

the portion I moved

          <?php if ($search_box): ?>
            <div id="search-box">
              <?php print $search_box; ?>
            </div> <!-- /#search-box -->
          <?php endif; ?>

and then modified this line by removing $search_box from the "if" "or" statement.

<?php if ($primary_links or $secondary_links or $navbar): ?>

and place the search code here

 </div> <!-- /#logo-title -->
      <?php endif; ?>

      <?php if ($header): ?>
        <div id="header-blocks" class="region region-header">
          <?php print $header; ?>
        </div> <!-- /#header-blocks -->
      <?php endif; ?>

          <?php if ($search_box): ?>
            <div id="search-box">
              <?php print $search_box; ?>
            </div> <!-- /#search-box -->
          <?php endif; ?>

    </div></div> <!-- /#header-inner, /#header -->

and then modified my fixed-layout.css here

  #search-box
  {
    width: 180px;
    margin-left: 780px;
margin-top: -56px;
    float: right;
  }

Everything seems to work fine and it looks like it is part of the header.

What I will probably do now is customize the button and input box but I have some other stuff to do first, lol.

anrikun’s picture

Thank you for your answer.
Yes I tried the same, but I want the search box in the right side bar, and right side bar's content is in the variable $right.
So I have created a custom block and assigned it to right side bar.
Now I would like to write a snippet inside this custom block to render the search box but copying pasting

<?php if ($search_box): ?>
  <div id="search-box">
  <?php print $search_box; ?>
  </div> <!-- /#search-box -->
<?php endif; ?>

doesn't work as $search_box is a template var not available from within a block snippet.
Obviously I'm doing it the wrong way (I'm still a newbie!): I don't know how to have the search box rendered from a block snippet.
If someone can help me...

crutch’s picture

O, I see. What I've done for that is edit the search.module

**
 * Form builder; Output a search form for the search block and the theme's search box.
 *
 * @ingroup forms
 * @see search_box_form_submit()
 * @see theme_search_box_form()
 */
function search_box(&$form_state, $form_id) {
  $form[$form_id] = array(
    '#title' => t(''),
    '#type' => 'textfield',
    '#size' => 12,
    '#default_value' => '',
    '#attributes' => array('title' => t('Enter Search Terms')),
  );
  $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
  $form['#submit'][] = 'search_box_form_submit';
  $form['#validate'][] = 'search_box_form_validate';

  return $form;
}

Make sure to make a copy to text file so you can quickly revert back if needed.

anrikun’s picture

You mean that you directly edited the core file?
I would like to override it inside my theme without editing the core file directly. But I don't know how yet: I'm still learning!
I'm a bit lost with hooks, themes, etc. :-D

crutch’s picture

10-4 I just do the core file. It is a small change and easy to update but I'd like to know how also.

lvthunder’s picture

I would like to know the best way to do this too. I need to alter it so it searches a third party module by default.

anrikun’s picture

First of all you should look at the search module in /modules/search/ to see how it works.
Then you could alter the search form by providing an implementation of hook_form_alter() in a custom module.

lvthunder’s picture

So I need to create a new module just to change the post action of search to go from /search/node to /search/gallery? Do you know of any examples I can use? I only know enough PHP to be able to edit the .tpl.php files.

anrikun’s picture

What is the gallery module you're using?

lvthunder’s picture

It's a photo management software. http://gallery.menalto.com. It uses the gallery module http://www.drupal.org/project/gallery. You can see what I'm trying to build at http://test.lvthunder.com. I have a block that makes search work the way I want it to, but I would like the zen search bar to do the same. That way I can take the search block out of the left sidebar.

anrikun’s picture

Do you really have to use zen search box then?
If the search box your site is using works, why don't you just modify you theme so that the box is not displayed in left sidebar but somewhere else?
If you need more help please post your theme's files.

lvthunder’s picture

Well I guess not. I just thought it would be easier to modify the zen one, but I guess I'm mistaken. Thanks for your help anrikun.

farez’s picture

You need to enable the search box by going into your theme config and then checking the 'Search box' checkbox. You'll then have the $search_box variable in your template file for the search box.

Farez

dgautsch’s picture

EDIT: Nvm, i solved my own issue.

I can't get my search box to appear on my sub theme. I checked the .info file and it is indeed enabled. But when I go to the theme config in Drupal the box is ghosted out. Is there any reason for this?

sethwilpan’s picture

Is the Search module enabled in Site Building/modules?

sh264’s picture

@sethwilpan: 2 different search options here.

yeh, enable the search module in yoursite.com/admin/build/modules
do your permissions or whatever
then stick your "Search form" block in a region: yoursite.com/admin/build/block

zen search is done through the theme, as above by ferez in #13: yoursite.com/admin/build/themes
then configure your theme, check the search box, save and style

sure you've figured it out by now.

kbk’s picture

@ #2 : Don't know if this helps but my "additional-search-box-in-a-block" problems were solved when I happened over here: http://drupal.org/node/611942

akalata’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sammyman’s picture

How do you accomplish this with drupal 7?

kbk’s picture

This issue is closed (and marked for D6.) You should probably open a new issue for your Drupal 7 question.