Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Customize Search field to do a Match All Search  (Read 4536 times)

0 Members and 1 Guest are viewing this topic.

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Customize Search field to do a Match All Search
« on: January 27, 2010, 07:08:43 am »

I found a code on your forum to add a search field to my template page so it would appear on all pages.


http://forum.coppermine-gallery.net/index.php/topic,19862.msg91165.html#msg91165

I instlaled it and it works. Unfortunately...it does the wrong kind of search. Instead of narrowing the results with each additional keyword, it broadens it. In other words...if I type in "birds" I get all the birds. But if I add "red" to the search (so now the field contains both "birds" and "red") the search returns all the birds AND everything that is red. So the search broadens ... which is not at all useful for me.

Can this code be tweaked so that when someone types in "bird" and "red" , it returns only red birds?  I guess this would be a "Match ALL words" search.

My site:   http://birdmarks.com/coppermine

Note...I don't have red birds on my site...but I will key in those words into certain pictures so you can see what I mean

Thanks
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Customize Search field to do a Match All Search
« Reply #1 on: January 27, 2010, 07:17:47 am »

Sorry..I forgot to include the code used:

Code: [Select]
<form method="get" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">
<input type="hidden" name="album" value="search">
<input type="hidden" name="type" value="full">
<input type="input" style="width: 90%" name="search" maxlength="255" value="" class="textinput">
<input type="submit" value="Search the file collection" class="button">
</form>
« Last Edit: January 27, 2010, 07:35:06 am by Joachim Müller »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Customize Search field to do a Match All Search
« Reply #2 on: January 27, 2010, 07:34:56 am »

By default, the search performs an OR logic of the keywords. Add
Code: [Select]
<input type="hidden" name="type" value="AND" />into a new line before
Code: [Select]
</form>in your custom code.

Please use the bbcode tags in this forum in the future; I edited your posting accordingly.
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Customize Search field to do a Match All Search
« Reply #3 on: January 27, 2010, 08:11:10 am »

Thanks,  I'll tweak my code. I looked for the bbcode to add a code box, but I couldn't find it. I'm trying my best to obey all your rules :-)
You guys have been really helpful.

Thanks
Logged

blueberg

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 48
Re: Customize Search field to do a Match All Search
« Reply #4 on: January 27, 2010, 09:12:09 am »


I made the addition to the search code as you instructed:

Code: [Select]
<form method="get" action="http://birdmarks.com/coppermine/thumbnails.php" name="searchcpg">
<input type="hidden" name="album" value="search">
<input type="hidden" name="type" value="full">
<input type="input" style="width: 90%" name="search" maxlength="255" value="" class="textinput">
<input type="submit" value="Search the file collection" class="button">
<input type="hidden" name="type" value="AND" />
</form>

But the results are the same. My search field still bring up an "OR" search instead of an "AND" search.

I tried various versions of the above code. I tried commenting out the full search line. I then deleted that line completely. The results were always the same. The code in my page now is the one you see above.

http://www.birdmarks.com/coppermine

I have made my search easier to test. I am using only 3 images. one has the keyword "wolf".
One has the keyword "black" and a third picture has both "black" and "wolf"

thanks again for your help. I think I found the right bbcode  ;D
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 19 queries.