Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: Custom Search Capabilities  (Read 323 times)

0 Members and 1 Guest are viewing this topic.

dpaulat

  • Contributor
  • Coppermine newbie
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 4
Custom Search Capabilities
« 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!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15471
Re: Custom Search Capabilities
« Reply #1 on: December 27, 2017, 03:24:18 pm »

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).
Logged

dpaulat

  • Contributor
  • Coppermine newbie
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 4
Re: Custom Search Capabilities
« Reply #2 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.
Logged

dpaulat

  • Contributor
  • Coppermine newbie
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 4
Re: Custom Search Capabilities
« Reply #3 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
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 20 queries.