Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: use a fixed keyword set in search  (Read 6031 times)

0 Members and 1 Guest are viewing this topic.

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
use a fixed keyword set in search
« on: April 01, 2010, 02:06:36 am »

My gallery application, http://clemsonphotos.org/coppermine (version 1.5 RC, guest access allowed), was developed using a fixed set of keywords available for each photograph.  When searching, it would be convenient to display a fixed set of keywords (a controlled vocabulary) that users could combine when searching.  Is this something that can reasonably be done by modifying code?  If so, how should I proceed?

Del
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: use a fixed keyword set in search
« Reply #1 on: April 01, 2010, 07:25:27 am »

Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: use a fixed keyword set in search
« Reply #2 on: April 01, 2010, 03:34:58 pm »

I read the documentation, including enabling clickable keywords.  I have an existing set of keywords, already applied to the files before  uploading.  I do not want to be able to search for a single keyword (which is what clickable keywords does, among other things).  I want to display a set of keywords that are constructed not by extracting them from uploaded file keywords, but from a fixed, static list.  Users could then enter these keywords, in combinations and to combine with other text, in the search dialog.  Searching for a single keyword is not helpful with my application, as it will return too many hits.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: use a fixed keyword set in search
« Reply #3 on: April 01, 2010, 04:11:08 pm »

You can use this plugin hook to modify the search page.
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: use a fixed keyword set in search
« Reply #4 on: April 01, 2010, 05:52:37 pm »

Thanks, Andre.  I am very new to this software, and to php, so I will think long and hard before trying this approach.  At first glance, it looks like I could replace the search page with this, and that might turn out to be what I need.  But, simpler approaches first.

I do appreciate the pointer to where I might productively add code.  That is one of the challenges for me, knowing where I need to look.

Del
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: use a fixed keyword set in search
« Reply #5 on: April 01, 2010, 06:37:48 pm »

You can do a string replace (str_replace) to include your stuff. In your case I would add some tags (e.g. a list), that appends the selected word to the search fields. That's very simple and all you needs is just some very basic skills in php and javascript.
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: use a fixed keyword set in search
« Reply #6 on: April 01, 2010, 06:50:32 pm »

I am having a little trouble understanding this.  Do you mean string replace to modify the set of search terms for a specific search, or string replace to replace segments of the search page as displayed to the user?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: use a fixed keyword set in search
« Reply #7 on: April 01, 2010, 07:47:16 pm »

Neither. The common way is to search for a specific string and add your content before/after that string. Of course you simply can add it to the start/end of the search form. That's your choice.
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: use a fixed keyword set in search
« Reply #8 on: April 01, 2010, 09:35:13 pm »

Can you direct me to a place where I could see an example of this approach?

Del
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: use a fixed keyword set in search
« Reply #9 on: April 01, 2010, 10:30:46 pm »

Example of what? I don't know your skills. What exactly do you want to know?
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: use a fixed keyword set in search
« Reply #10 on: April 01, 2010, 10:39:28 pm »

An example of using string replace to add content to a page using the API hook for Search.  My skills are ahead of my knowledge in this kind of programming.  Quite a bit of experience, some with Perl, but very little with PHP.

Del
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: use a fixed keyword set in search
« Reply #11 on: April 02, 2010, 08:05:42 am »

Have a look at search.php. Everything in the variable $text can be accessed and modified with the plugin hook 'search_form'. Now it's your choice. Either you want to place your list somewhere in the search form box. Then you have to use str_replace. If you want to display that list at the place where the actual keywords are listed, your plugin code have to look like this:
Code: [Select]
<?php
$thisplugin
->add_filter('search_form''custom_search_form');

function 
custom_search_form($text) {
  
// here comes your html and js stuff
  
$keyword_list '<span onclick="foo">bar</span>';

  
// then you append your list to the search form
  
$text .= $keyword_list;

  return 
$text;
}
?>
Logged

clemphoto

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 34
Re: use a fixed keyword set in search
« Reply #12 on: April 02, 2010, 04:05:51 pm »

Got it!  Thanks very much, Andre.
Logged
Pages: [1]   Go Up
 

Page created in 0.064 seconds with 19 queries.