I am running Drupal 4.7.4 and I am seeing something I haven't seen before with my search block (other Drupal sites have worked in the past).

The problem is that entering a search in my left side block search block brings me to the search node (.../search/node) without the search in the search text field of the search/node or in the URL. When I type in my search within the text box in the main content area of the search node, the search works.

Does anyone have an idea of what could be causeing this?

BTW, my test site is http://www.pittsfordcc.org/drup474. Try doing a search on my name 'Rich' if you want to witness it first hand.

Thanks.

Rich
(rl)

Comments

krewemaynard’s picture

I'm having similar trouble with Drupal 5.0. If I restrict the search block to a particular node, the initial search takes you to the search node, not the results. However, if I show the block site-wide, it works fine. That's kinda not what I want, but it works for now. :) http://qualityblueprint.com

pommac’s picture

I had the same problem - when searching from the input block in my page, I got to the results page but no search was performed. When searching from the result page, everything worked fine. I solved it thusly in template.php:

function phptemplate_search_block_form($form) {
  $form["id"] = "search-form";
  return _phptemplate_callback('block-search-box', array('form' => $form));
}

This code uses block-search-box.tpl.php to style the search block, but the key to getting it working is in the ID. When displayed as a block, the form id is "search-block-form" and for some reason this won't work. It needs to be "search-form" instead.

rl’s picture

I added your function to my template.php file in my theme and no search input box appeared. I do have the search block only enabled on the front page. Does anyone have a fix for 4.7.4, or did I not implement your fix incorrectly?

I get this error - "PHPTemplate was instructed to override the block-search-box theme function, but no valid template file was found."

Thanks for all the info.

Rich

naren’s picture

Pommac

would you please tell me that with which version your patch is compatible?? and if possible would you give me a solution for 5.0 beta...
Your patch does not seem to work with 5.0 beta

thanx in advance

davegan’s picture

A quick and easy way to fix this problem is to just create a custom block and put the form code for the main search page inside it:

<form action="<?php print base_path() ?>search/node"  method="post" id="search-form" class="search-form">
<input type="text" maxlength="128" name="keys" id="edit-keys"  size="10" value="" class="form-text" />
<input type="submit" name="op" id="edit-submit" value="Search"  class="form-submit" />
<input type="hidden" name="form_token" id="edit-search-form-form-token" value="<?php print drupal_get_token('search_form'); ?>"  />
<input type="hidden" name="form_id" id="edit-search-form" value="search_form"  />
</form>

Note: this code is for Drupal 5.1. May have to customize for other versions.

svogel’s picture

Hi davegan,

your snippet solved my problem in Drupal 4.7 (without modifications).
Thanks a lot for that.
Stefan

kingandy’s picture

Note that this snippet only works if your site correctly interprets clean URLs. For a more robust block, replace base_path() with url():

<form action="<?php print url('search/node') ?>"  method="post" id="search-form" class="search-form">
<input type="text" maxlength="128" name="keys" id="edit-keys"  size="10" value="" class="form-text" />
<input type="submit" name="op" id="edit-submit" value="Search"  class="form-submit" />
<input type="hidden" name="form_token" id="edit-search-form-form-token" value="<?php print drupal_get_token('search_form'); ?>"  />
<input type="hidden" name="form_id" id="edit-search-form" value="search_form"  />
</form>

Apart from that, awesome, this is exactly what I'm looking for :D

++Andy

themselves’s picture

Exact same problem for me, used this code, worked perfectly. Thanks!

quinti’s picture

Hi guys

this snippet and "Show on every page except the listed pages" with the following:
search/node/*search/node/*

work in Drupal 6

nice

baronmunchowsen’s picture

I am experiencing this problem also with a Drupal 5.1 install.

A search in the search block brings me to the search page (search/node) with no search having been processed. Once you search from the form on the main page, rather than the block - it's all good.

This is the <form> tag from the search BLOCK:

<form action="/search/node" method="post" id="search-block-form">

and from the search PAGE:

<form action="/search/node" method="post" id="search-form" class="search-form">

any ideas?

justin3’s picture

still broken- has anyone found a solution for this in 4.7?

baronmunchowsen’s picture

The only resolution I have found is to have the search activated on every page. This stops it for me. Not ideal by any stretch, but it will do.

mishhh’s picture

1. Disable the search block (Go to "administer -> site building -> blocks" for this)

2. enable the search box (Go to "administer -> site building -> theme -> your theme" and enable the checkbox for search)

3. then modify the page.tpl.php in this way:

instead of:

if ($searchbox) {...}

write:

if ($searchbox && arg(0) != 'search') {...}

in this way the searchbox will not be displayed on the search page.

It works for me.
:)

tregeagle’s picture

I'm using Drupal 5 and was getting the same problem.

Using the default search block with the "Page specific visibility settings" set to "Show on every page except the listed pages" with the following:
search/node*

I changed it to:
search/node/*

and now it works

cheers
- ruben

smokingtrucks’s picture

This works flawlessly on 4.7.

I was using 'search/*' as my block exception filter.

I've changed the exception filter to 'search/node/*'.

Simple fix, kudos Ruben.

klance’s picture

mtboxtech’s picture

I've tried just about every fix suggested on this page, from editing template.php, to making a custom search block, to adding in various other bits of code, to making the search block visible on on certain pages, etc. Nothing seems to fix my issue. Search works but only from the search page, not from the search block.

chrisroditis’s picture

This is what worked for me
set block visibility for the search block to "show only the listed pages" and then set them to
search/node/*
search/node
Hope that works!

Christopher Skauss:my personal blog and The Thelo:my band
Open Music: the universal music revolution

A healthy disregard for the impossible.

fmitchell’s picture

This is weird that this problem has propagated through 4.7 all the way to Drupal 6.6

--
Fredric
http://brightplum.com

yesct’s picture