Hi I'm trying to change the default search form in the theme from ANDed to ORed, in order to be able and search in phrases containing any of the words instead of the complete phrase.

For instance if I'm looking for info about "Paris Hilton" but instead of writing the whole phrase I just write "Paris Hil"; by default it would lead to a no results page, but if ORed it would give me as a result any article containing at least the word "Paris".

I've tried doing this but with no success:

First I've added the following function override in template.php

and then I've created a file named search-theme-form.tpl.php with the following lines:




print drupal_get_token('search_theme_form'); " />

The first line replaces the default

But unfortunately when doing a search it returns the following message "Please enter some keywords.
".

Any help really appreciated since I'm going crazy with this one.

Thank you in advance.

Comments

GuybrushSThreepwood’s picture

sorry this is the code in search-theme-form.tpl.php

input type="text" maxlength="128" name="or" id="edit-or" size="15" value="" title="Enter the terms you wish to search for." class="form-text" /
input type="submit" name="op" id="edit-submit" value="Search" class="form-submit" /
input type="hidden" name="form_id" id="edit-search-theme-form" value="search_theme_form" /
input type="hidden" name="form_token" id="edit-search-theme-form-form-token" value="<?php print drupal_get_token('search_theme_form'); ?>" /
input type="hidden" name="module" id="edit-module" value="node"  / 

Thanks again

GuybrushSThreepwood’s picture

Any help please?

bdew70’s picture

I know this has been fours years--and I hope you see this---and may not even need it anymore but...

in root folder(with search module installed) go to modules/search

open up search.module

add this line: $keys = str_replace(' ',' OR ',$keys);

at ~line 1160 to function below so it looks like this:

function search_data($keys = NULL, $type = 'node') {

  if (isset($keys)) {
    if (module_hook($type, 'search')) {
    	 $keys = str_replace(' ',' OR ',$keys);//ADD THIS LINE!!!
      $results = module_invoke($type, 'search', 'search', $keys);
      if (isset($results) && is_array($results) && count($results)) {
        if (module_hook($type, 'search_page')) {
          return module_invoke($type, 'search_page', $results);
        }
        else {
          return theme('search_results', $results, $type);
        }
      }
    }
  }
}

Took me forever to find.