forum.coppermine-gallery.net

Support => cpg1.6.x Support => cpg1.6 plugins => Topic started by: dpaulat on December 24, 2017, 09:37:14 pm

Title: Custom Search Capabilities
Post by: dpaulat on December 24, 2017, 09:37:14 pm
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!
Title: Re: Custom Search Capabilities
Post by: Αndré on December 27, 2017, 03:24:18 pm
Please have a look at the "More meta albums" plugin (http://forum.coppermine-gallery.net/index.php/topic,63706.0.html) 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).
Title: Re: Custom Search Capabilities
Post by: dpaulat on December 27, 2017, 07:09:08 pm
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.
Title: Re: Custom Search Capabilities
Post by: dpaulat on December 31, 2017, 07:18:57 pm
I've created a pull request to propose merging this into the development branch:
https://github.com/coppermine-gallery/cpg1.6.x/pull/16