4images Forum & Community

4images Issues / Ausgaben => Discussion & Troubleshooting => Topic started by: Chris on October 03, 2002, 04:36:17 AM

Title: Search Constructors "OR", "AND" question
Post by: Chris on October 03, 2002, 04:36:17 AM
I have images of two people.  In the description fields, I have entered their names.  They are:

Clint Macbeth
Keith Macbeth

Using the Advanced Search form, if I enter "Keith Macbeth" in the search_keywords form field and click the "AND" search constructor radio button, I get all images from both people.  If I enter "Keith AND Macbeth" in the search_keywords form field, I get only the images of "Keith Macbeth".

So what purpose does the "search constructor" serve?
Title: Search Constructors "OR", "AND" question
Post by: Jan on October 03, 2002, 10:40:01 AM
Try this:

Add in search.php after
Code: [Select]
elseif (is_array($search_word_cache[$i])) {
this code
Code: [Select]
if ($search_terms) {
  $operator = "and";
}

Jan
Title: Thanks
Post by: Chris on October 03, 2002, 02:13:50 PM
Cool, that fixed it.
Title: Another way to make all searches default to use ALL terms entered
Post by: Chris on October 14, 2002, 01:25:38 AM
Update:

If you want to make the "search_bar" search form also default to ALL words entered instead of ANY, you can add the following to the html form:
Code: [Select]
<input type="hidden" name="search_terms" value="all" />
or you can open search.php, look for
Code: [Select]
if (isset($HTTP_POST_VARS['search_terms'])) {
  $search_terms = (trim($HTTP_POST_VARS['search_terms']) == "all") ? 1 : 0;
}
else {
  $search_terms = 0;
}

and change this line
Code: [Select]
 $search_terms = 1;  // Makes default search use ALL terms entered
}