Author Topic: Search Constructors "OR", "AND" question  (Read 4052 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Search Constructors "OR", "AND" question
« 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?

Offline Jan

  • Administrator
  • 4images Guru
  • *****
  • Posts: 5.024
    • View Profile
    • 4images - Image Gallery Management System
Search Constructors "OR", "AND" question
« Reply #1 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
Your first three "must do" before you ask a question:
1. Forum rules
2. FAQ
3. Search

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Thanks
« Reply #2 on: October 03, 2002, 02:13:50 PM »
Cool, that fixed it.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Another way to make all searches default to use ALL terms entered
« Reply #3 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
}