use a fixed keyword set in search use a fixed keyword set in search
 

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

use a fixed keyword set in search

Started by clemphoto, April 01, 2010, 02:06:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

clemphoto

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

Joachim Müller


clemphoto

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.

Αndré

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

clemphoto

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

Αndré

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.

clemphoto

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?

Αndré

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.

clemphoto

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

Del

Αndré

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

clemphoto

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

Αndré

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:
<?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;
}
?>

clemphoto