We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27424
    • 18 Posts
    Hi, is there any way to apply TagCloud to the WebUsers?

    Just to obtain a tag cloud of the country that they put in their profile and, of course, link to the profile pages.
      who dares win
      • 27424
      • 18 Posts
      allright... wasn’t too hard to change the TagCloud snippet... now.... It merges all the tags in a single link.... how can I fix it!?
      <?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 : "1";
      $landing = isset($landing)? $landing : "[~[*id*]~]";
      
      
      $exclude = array('',' ','  ','   ','and','a','-','ó','–','the','—','to','.',':',','); 	//exclude list
      $zeichen = array(',','.',':');		//array of chars to be deleted
      if (strpos($parent,',')){
      	$parent= explode(',',$parent);
      }
      
      $table = $modx->getFullTableName("web_user_attributes");
      		$select = $modx->db->select("state", $table);	// record: country
              // For updates: Remember to set the country varchar to 200, in the database
      		while ($contents = $modx->db->getRow($select)) {
      			$content.=$contents['state'];  //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="[~'.$landing.'~]&FSF_search='.$key.'">'.$key.'</a>'.$countvalues.'</span>  ';
      		$output.="\r\n";
      	}
      $output.='</div>';
      return $output;
      ?>
      

      mod note: please wrap into code tags.
        who dares win
        • 27424
        • 18 Posts
        ops, found it grin

        I forgot to put a blank space between the words, so the explode can work correctly.

        now... how should I change the search result page?

        ps. why the link are like: http://localhost/~denis/modx/[~’9’~]&FSF_search=barcellona
        ???
          who dares win