Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
testy1
Involved
Involved



Joined: Apr 06, 2008
Posts: 484

PostPosted: Wed Aug 06, 2008 7:52 pm Reply with quote

i've created a block based on some phpbb3 stuff that i saw that displays a list of the 50 most common words in the forum.It works great but i want to stop it from displaying common words and words smaller than say 3 characters, now i know this is intergrated into the search part of phpbb but not sure if is usuable in this block.

the forum uses search_stopwords.txt is it possible to intergrate this somehow using maybe an array.

here is the code for the block.

Code:


<?php

if ( !defined('BLOCK_FILE') ) {
    Header('Location: ../index.php');
    die();
}

$content = '';
$words_array = array();
global $db, $prefix;
// Get words and number of those words
$sql = 'SELECT l.word_text, COUNT(*) AS word_count 
   FROM ' . $prefix . '_bbsearch_wordlist AS l, ' . $prefix . '_bbsearch_wordmatch AS m
   WHERE m.word_id = l.word_id
   GROUP BY m.word_id
   ORDER BY word_count DESC';
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
   $word = strtolower($row['word_text']);
   $words_array[$word] = $row['word_count'];
}
$db->sql_freeresult($result);

$minimum = 1000000;
$maximum = -1000000;

foreach ( array_keys($words_array) as $word )
{
   if ( $words_array[$word] > $maximum )
   {
      $maximum = $words_array[$word];
   }
   
   if ( $words_array[$word] < $minimum )
   {
      $minimum = $words_array[$word];
   }
}

// ratio
$ratio = ( ($maximum - $minimum) != 0) ? 4 / ( $maximum - $minimum) : 4 ;

$words = array_keys($words_array);
sort($words);

foreach ( $words as $word )
{
     $wordstyle = "style=\"font-size:".(9 + ( $words_array[$word] * $ratio ))."pt\"";
     $content .= "<a $wordstyle href=\"fsearch-results.html?search_keywords=".urlencode($word)."\"> ".$word ." </a>";
}

?>


it works great and also makes the words bigger if thewy have been used more, and if you click it, it will display the search results for that word.

any help is appreciated.
 
View user's profile Send private message
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Wed Aug 06, 2008 11:12 pm Reply with quote

Try this

Quote:

WHERE m.word_id = l.word_id AND CHAR_LENGTH(l.word_text) > 3

_________________
- Star Wars Rebellion Network -

Need help? Nuke Patched Core, Coding Services, Webmaster Services 
View user's profile Send private message Visit poster's website
testy1







PostPosted: Wed Aug 06, 2008 11:30 pm Reply with quote

are thats it cheers m8
 
testy1







PostPosted: Wed Aug 06, 2008 11:47 pm Reply with quote

Still needs some work but is up and running anyway Smile

might need to work on the common words problem eventually
 
warren-the-ape
Worker
Worker



Joined: Nov 19, 2007
Posts: 196
Location: Netherlands

PostPosted: Thu Aug 07, 2008 2:41 am Reply with quote

Hey a tagcloud, nice idea Cool
Would you be willing to share it once you finished it?
 
View user's profile Send private message
testy1







PostPosted: Thu Aug 07, 2008 4:48 am Reply with quote

yer here it is so far

Click Here
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©