We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30562
    • 99 Posts
    Here so works correctly for me:
    <?php
    /****************************************************
    * Name: Tagcloud
    * Version: 1.1.
    * Desc: Displays the containing words of documents in a "tag cloud"
    * created by Marc Hinse, [email protected], www.modxcms.de
    * update: 25.04.06 - minor bugfix
    *
    * 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)
    * ***************************************************/
    
    $parent = isset($parent)? $parent : "0";
    $min = isset($min)? $min : "2";
    $landing = isset($landing)? $landing : "[~[*id*]~]";
    
    $exclude = array('',' ','  ','   ','and','a','-','—','–','the','—','to','.',':',','); 	//exclude list
    $zeichen = array(',','.',':');		//array of chars to be deleted
    $parent= explode(',',$parent);
    
    $content = "";
    $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=mb_strtolower(str_replace($zeichen,'',$modx->stripTags($content)),'UTF-8');	//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="[~'.$landing.'~]&FSF_search='.$key.'">'.$key.'</a>'.$countvalues.'</span>  ';
    		$output.="\r\n";
    	}
    $output.='</div>';
    return $output;
    ?>
      • 16702 ☆ A M B ☆
      • 536 Posts
      Hi guys,

      can i sort/order results by parent?

      For example:

      i have tag: "car"

      and results:
      1. my BMW and my life
      2. World trip with my car
      3. New light
      4. From Berlin to Paris
      5. new Z3 - big day

      but i need sort by parent like this:

      My car`s:
      my BMW and my life
      new Z3 - big day

      Trip`s:
      World trip with my car
      From Berlin to Paris

      Blog:
      New light

      How make this?

      !0x
        palma non sine pulvere