This TagCloud script is useless “as-is” but it will create a tagcloud.
/**************************************************** * Name: Tagcloud * Version: 0.2 * Desc: Displays the containing words of documents in a "tag cloud" * Based on the Tagcloud 1.1. snippet created by Marc Hinse, [email protected] * Converted to EtomiteCMS by Bogge, bogge.com * * Change 0.1 => 0.2 Removed explode $parent and optimized sql query. Thanks to adamzyg. * * Usage: [[tagcloud?parent=`1,3,5,6,7,14`&min=`3`&landing=`12` * Parameters: * parent: comma separated list of the folders that conatin the documents which are to be counted * min: Minimum occurrences of a word to be displayed * landing: the id of your search result page. If you don´t have one, create it like: [!FlexSearchForm?FSF_showResults=`1` &FSF_showForm=`0`!] * (this is required for linking the tags) * ***************************************************/ //Start Config $parent = isset($parent)? $parent : "0"; $min = isset($min)? $min : "2"; $landing = isset($landing)? $landing : "[~[*id*]~]"; $minChars = 4; //Minimum number of chars in word $exclude = array('',' ',' ',' ','and','a','-','—','–','the','—','to','.',':',',','på',' '); //exclude list $indication = array(',','.',':'); //array of chars to be deleted //End Config If (!$tags) { $select = $etomite->getIntTableRows($fields="pagetitle,longtitle,description,content", $from="site_content", $where="parent IN ($parent) AND published = 1 AND searchable=1 AND deleted=0", $sort="", $dir="", $limit="", $push=false, $addPrefix=true); while ($contents = $etomite->fetchRow($select, $mode='both')) { $content.=$contents['pagetitle'].' '.$contents['longtitle'].' '.$contents['description'].' '.$contents['content']; } $content=strtolower(str_replace($indication,' ',strip_tags($content))); //all to lower and without HTML $array_content=explode(' ',$content); //split them in separate words $number=array_count_values($array_content); //count the words $words=array(); foreach($number as $key => $worth) { if($worth>$min && (!in_array($key,$exclude) && (strlen($key) >= $minChars))) { //look if the word counts the required minimum and is not in the exclude list $words[$key] = $worth; //put them in a new array } } } else { $words=array(); foreach($tags as $tag) { if($tag['count']>=$min && (!in_array($tag['tag'],$exclude))) { $words[$tag['tag']] = $tag['count']; } } } //unset($words['etomite']); //if you want to override the value of words (in this case 'etomite'), uncomment it and put in your word $max_size=max($words); //word with most hits //$words['etomite']=8; // put in again your deleted word and value from two lines above ksort($words); //sort them alphabetically (just comment that out, then they will be unsortet $multiplier=400/$max_size; //define the multiplier for the size (play with that to fit your site!) $min_size=80; //minimum size $output='<div class="tagcloud">'; foreach($words as $key => $worth) { $font_size=$multiplier*$worth; //$countvalues='('.$worth.')'; //uncomment this for displaying the hits next to the links $output.='<span><a style="font-size:'.max($font_size,$min_size).'%;" href="[~'.$landing.'~]&FSF_search='.$key.'">'.$key.'</a>'.$countvalues.'</span> '; $output.="rn"; } $output.='</div>'; return $output;
This entry was posted in Etomite CMS. Bookmark the permalink