Customize Search field to do a Match All Search Customize Search field to do a Match All Search
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Customize Search field to do a Match All Search

Started by blueberg, January 27, 2010, 07:08:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blueberg

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

blueberg

#1
Sorry..I forgot to include the code used:

<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>

Joachim Müller

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

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

blueberg

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

blueberg


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

<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