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

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

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