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: Limit keywords - How to?  (Read 2166 times)

0 Members and 1 Guest are viewing this topic.

tinorebel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 87
  • live long and prosper!
    • www.tripodart.net
Limit keywords - How to?
« on: September 17, 2008, 08:04:01 pm »

I was wondering if there is a simple way to limit the keywords displaying under the search to -for example- the 50 keywords with more referenced files. Or maby it could bee done by limiting the keywords to only the ones which have 10 referred pictures.
I have tons of keywords and if I display them all the page gets huge and slows down quite a lot.
tahnks for any idea.
Logged
Live long and prosper!
www.tripodart.net

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Limit keywords - How to?
« Reply #1 on: September 17, 2008, 08:22:17 pm »

The stuff that takes so long to display the keywords is not the creation of the output, but running the queries against the database. Firguring out what are the most frequently used keywords would mean running even more quires against the database, which would make things even slower. So there is no easy solution: the most frequently used keywords would have to be stored in a sort of cached table, which would in turn mean a lot of extra coding. Sorry: no easy answer.
For busy sites I suggest turning the display of keywords off.
Logged

Nibbler

  • Guest
Re: Limit keywords - How to?
« Reply #2 on: September 17, 2008, 09:02:10 pm »

Seems easy enough to me. Edit include/keywords.inc.php, find

Code: [Select]
       if (!in_array($word = utf_strtolower($word),$keywords_array)) $keywords_array[] = $word;

change to

Code: [Select]
       $keywords_array[utf_strtolower($word)]++;

Then find

Code: [Select]
  // Sort selected keywords
  sort($keywords_array);

change to

Code: [Select]
  // Sort selected keywords
  arsort($keywords_array);
  $keywords_array = array_slice(array_keys($keywords_array), 0, 50);

Change the 50 to however many keywords you want displayed.
Logged

tinorebel

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 87
  • live long and prosper!
    • www.tripodart.net
Re: Limit keywords - How to?
« Reply #3 on: September 18, 2008, 11:04:56 am »

 ;D ;D ;D  Yess! WORKS LIKE A CHARM!!! ;D ;D ;D
tahnks nibbler, your mod is going to be really usefull!
Now the most important keywords appear quickly under the search field!!!

I never used cliccable keywords in search because they were too many, maby it could be a usefull feature to be included in future versions of cpg.
I have alsaw noticed the keywords are listed not in alphabetical order but in importance (number of referrenced files) order.
Thats excelent for my purposes. Anytime you need a photo, just tell me and I will be happy to search and send it to you!

Just a silly question: Could I easly retrive this information in a php document?

Have a nice time.
Logged
Live long and prosper!
www.tripodart.net
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.