Limit keywords - How to? Limit keywords - How to?
 

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]

Main Menu

Limit keywords - How to?

Started by tinorebel, September 17, 2008, 08:04:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

tinorebel

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.
Live long and prosper!
www.tripodart.net

Joachim Müller

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.

Nibbler

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


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


change to


       $keywords_array[utf_strtolower($word)]++;


Then find


  // Sort selected keywords
  sort($keywords_array);


change to


  // 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.

tinorebel

 ;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.
Live long and prosper!
www.tripodart.net