Help Making Search Function More Specific Help Making Search Function More Specific
 

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

Help Making Search Function More Specific

Started by Chili, June 23, 2006, 05:33:35 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chili

Like the original poster in this thread http://forum.coppermine-gallery.net/index.php?topic=30310.msg140285#msg140285 I also shoot motorsports and title my photo's by the bike #, I also use the riders name as well.  I'd like to narrow the search down so if you do a search for #9 you get only #9 and not any number with the #9 in it.  I've tried the fix in the above linked thread numerous times and even acquired the amended file from that original poster since we are acquainted, yet all that edit does is make my search stop finding any results.  The only difference I can think of is I believe his is searching the caption of the metadata while mine is entered into the title bar in coppermine.

Any assistance is greatly appreciated.

Chili


Nibbler

The way I described in that post is the way to do it. Apply the mod, enable debug mode, and post a link to your gallery for support.

Chili

Mod applied, search no longer works at finding any results.  debug mode enabled, I'm hoping this is what has caused my gallery to all of the sudden stretch sideways to extremely wide width?  Gallery can be found at http://www.holeshotphotography.net/gallery

Nibbler

OK, I see why. Also make this change in search.inc.php

$split_search = explode(' ', $search_string);

change to

$split_search = array($search_string);

and to allow searching of characters like the #, modify

$search_string = preg_replace('/[^0-9a-z %]/i', '', $search_string);

so that it includes such characters.

Chili

Ok I think I'm part way home!  Now if I search by the exact phrase I've entered in the title I get results, however if I'm looking for say #91 Colin Cyr and only use 91 as my search criteria I get nothing, same for #91 etc it needs to be the complete title to find the result.  Is it possible to have it find on partial search results but only with the full number?  ie if #91 Colin Cyr comes looking for his photo's and uses any of the following as search criteria: 91, #91, Colin Cyr, 91 Cyr.  The way it was prior to any mods was fine for partial searches for names just not numbers.  I hope I'm not expecting too much, and I hope I've somehow rambled enough to make what I'm after clear enough.  Thank you for giving this some time Nibbler, It is very much appreciated. 

Nibbler

OK, reverse all mods and then change

if (in_array($param, $allowed))$fields[] = "$param LIKE '%$word%'";

to

if (in_array($param, $allowed))$fields[] = is_numeric($word) ? "$param RLIKE '[^0-9]{$word}[^0-9]'" : "$param LIKE '%$word%'";

Chili


Walkinman

Hey Folks

Does this still work for cpg 1.5.12? I tried the mods and simply got the "doesn't yield any results" result. From what I gather, the only mod needed should be the one posted above in Nibbler's final reply?
Quote from: Nibbler on June 29, 2006, 01:08:05 AM
OK, reverse all mods and then change

if (in_array($param, $allowed))$fields[] = "$param LIKE '%$word%'";

to

if (in_array($param, $allowed))$fields[] = is_numeric($word) ? "$param RLIKE '[^0-9]{$word}[^0-9]'" : "$param LIKE '%$word%'";

Is that correct? I've removed the mods until I can find out an answer, but my site is at Skolai Images

Thank you.

Cheers

Carl

Walkinman

Hey Folks,

I've finally switched things over to a live site, so the url for my gallery is http://www.skolaiimages.com/stock/

Would really like to have the option for 'search exact terms'. Currently, for example, a search for "Mount St. Elias" yields all named mountains in Wrangell - St. Elias National Park. Does this above mod still work in cpg1.5 or is there another way to achieve this?

Thank you.

Cheers

Carl