Custom Search Capabilities Custom Search Capabilities
 

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

Custom Search Capabilities

Started by dpaulat, December 24, 2017, 09:37:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

dpaulat

I am implementing a plugin that creates an index table with search terms.  My goal is to modify the search results to include results from my new index table when selected.  I've added a checkbox using the "search_form" filter, and am now working the backend of the search.

Initially, it seemed like "thumb_caption_search" might be a good filter to use, as I can modify the search results directly.  However, it seems I would lose the pagination functionality, and some other variables set in search.inc.php.

After deliberation, it seems what I would like to do is modify the actual search query in search.inc.php.  More specifically, I believe I am looking for a few new hooks, with the following capabilities:
- Modify $allowed array
- Join additional tables
- Modify WHERE clause
would like to join an additional table (my index table), potentially multiple times, and modify the WHERE clause with a new hook.

I've made some changes in a fork of cpg1.6.x that are working for me.  Can anyone advise of an alternative, or does this seem like the best approach?

https://github.com/coppermine-gallery/cpg1.6.x/compare/develop...dpaulat:dev/custom_search

Thanks in advance for any feedback!

ΑndrĂ©

Please have a look at the "More meta albums" plugin how to add a new meta album. I've created a custom search form for my personal gallery that way.

Most important plugin hooks are "meta_album" and "meta_album_get_pic_pos". You maybe also want to use "theme_thumbnails_album_types" (when adding an album search) and "page_start" (keep in mind that plugin i18n is already built-in in cpg1.6.x).

dpaulat

Thanks for the example!

I'm not sure the new meta album works for my scenario though.  Since posting, I think the work that I have is stable enough to share at this point:
https://github.com/dpaulat/cpg-plugin-extensible-metadata

My plugin will pull XMP metadata fields from the picture, and place search terms into an index table, which I use to integrate into the existing search functionality, similar to a keyword search.  I'm not using the metadata fields to create a meta album.  The relevant usages of the search filters are the hooks "search_form", "custom_search_params_allowed", "custom_search_param", and "custom_search_query_join", in codebase.php.

dpaulat

I've created a pull request to propose merging this into the development branch:
https://github.com/coppermine-gallery/cpg1.6.x/pull/16