Hello,
i modified this snippet:
http://modx.com/extras/package/?id=tagcloud
Being lazy i just used the same upload folders as the snippet suggested for evo, but then i modified the php:
<?php
/****************************************************
* Name: Tagcloud
* Version: 1.1.2
* Desc: Displays the containing words of documents in a "tag cloud"
* created by Marc Hinse, [email protected], www.modxcms.de
* modified by Iade Gesso, [email protected], www.iadegesso.netsons.org
* [modified and ported to revolution on 16th April 2011 by Nico Baden, [email protected], www.nedab.de]
* update: 19.11.09 - AjaxSearch adaptation
* 24.11.09 - Added stop words support (english, french, italian)
*
* Usage: [[tagcloud? &parent=`1,3,5,6,7,14` &min=`3` &landing=`suchergebnisse.html` &landing_id=`29` &lang=`en,it,de`]]
* 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 alias of the search result page
* landing_id: the id of the search result page to land on
* lang: comma separated list of languages for which load lists of stop words (default: en)
* ***************************************************/
$parent = isset($parent)? $parent : "0";
$min = isset($min)? $min : "2";
$landing = isset($landing)? $landing : "search.html";
$landing_id = isset($landing_id)? $landing_id : "[[~id]]";
$lang = isset($lang)? $lang : "en";
$lang = explode(',',$lang); // languages array
$exclude = array('',' ',' ',' ','-','?','–','—','.',':',','); //exclude list
$zeichen = array(',','.',':'); //array of chars to be deleted
// Path
define('TC_SPATH', 'assets/snippets/tagcloud/');
//include snippet file
define('TC_PATH', $modx->config['base_path'].TC_SPATH);
foreach($lang as $l) {
@include TC_PATH.'stopwords/'.$l.'.inc.php';
$exclude = array_merge($exclude, $sws);
}
if (strpos($parent,',')){
$parent= explode(',',$parent);
}
$table = $modx->getFullTableName("site_content");
foreach ($parent as $daddy){
$select = $modx->db->select("pagetitle,content,introtext", $table, "parent = $daddy"); // record: title, content, introtext
while ($contents = $modx->db->getRow($select)) {
$content.=$contents['content'].' '.$contents['introtext'].' '.$contents['pagetitle']; //put them together
}
}
$output='<div class="tagcloud">';
$content=strtolower(str_replace($zeichen,'',$modx->stripTags($content))); //all to lower and without HTML
$array_content=explode(' ',$content); //split them in separate words
$anzahl=array_count_values($array_content); //count the words
$words=array();
foreach($anzahl as $key => $wert) {
if($wert>$min && (!in_array($key,$exclude))) { //look if the word counts the required minimum and is not in the exclude list
$words[$key] = $wert; //put them in a new array
}
}
//unset($words['modx']); //if you want to override the value of words (in this case 'modx'), uncomment it and put in your word
$max_size=max($words); //word with most hits
//$words['modx']=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=300/$max_size; //define the multiplier for the size (play with that to fit your site!)
$min_size=30; //minimum size
foreach($words as $key => $wert) {
$font_size=$multiplier*$wert;
//$countvalues='('.$wert.')'; //uncomment this for displaying the hits next to the links
$output.='<span><a style="font-size:'.max($font_size,$min_size).'%;" href="'. $modx->config['base_url'] . $landing.'?search='.$key.'&id='.$landing_id.'">'.$key.'</a>'.$countvalues.'</span> ';
$output.="\r\n";
}
$output.='</div>';
return $output;
Have Fun!
PS: i attached a transport file, and hope everything is ok.
Would be nice to have the transport file as a download, a real developer may check and upload it.
PPS: its done for use with friendly url.