We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    Sorry guys, I have been pretty busy since that last message. The tagcloud snippet that we created for the repository looks at a tvar for each document and creates the tag cloud from the tags that are included in the tvar. So there is no include/exclude list because it only outputs tags that yuo have assigned to the document in the tvar, it does not search through the content like the current snippet.

    I have a version close to working outside of the repository, but have a few changes that still need made. I will try to get it done asap.
      • 6726
      • 7,075 Posts
      Thanks Kyle for the update smiley
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 34162
        • 1 Posts
        OK, so, what kyle has done for the repo is more or less what marc calls "cheating tagging" (or using categories via a tvar).
        So, what do you think: will it be useful to rewrite my include-list version of "content-based" cloud-making?

        best regards,
        paul
          • 17883
          • 1,039 Posts
          Hi Paul,

          please don´t misunderstand my interpretation of "cheating". My intention while writing this snippet was to display the "real" amount of words occuring in the documents without influence of (always subjective) tags. But of course tagging makes sense and of course a include list is useful (and I learned that because my exclude list is growing and growing). So please go ahead and rewrite like you wish, every efford for modx makes sense wink

          Regards,
          Marc
            • 7923
            • 4,213 Posts
            Yes, I too would like to see a refined version of the snippet ppaul. I think it would be very usefull to have, and will differ from the one kyle has made/is making.


              "He can have a lollipop any time he wants to. That's what it means to be a programmer."
              • 15987
              • 786 Posts
              I have added the tvtagcloud snippet to the repository. I still need to add to the instructions but it should get you going if you want to use it. You can get it here :http://modxcms.com/TvTagCloud-734.html
                • 34162
                • 1 Posts
                OK then. I’ll do the following:
                1. optimizing the last version (i.e. not doing an "any-to-any" match of all the words, but just counting the words from the include list.)
                2. trying to figure out how to do it without "exploding" the whole site-content into a real huge array - which might bounce RAM limits in larger sites - i.e. doing it directly in the database, if possible including existing TVs.
                The first thing is not such a big issue, the second, however, might take some time.

                regards, it’s a real pleasure to be here in this great forum!

                paul
                  • 6726
                  • 7,075 Posts
                  That’s great Kyle, I happen to have a need for it, so thanks for sharing grin
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l'outil id
                    • 34162
                    • 1 Posts
                    I promised a new version of the "TagCloudInc" snippet.
                    Well, here it is:
                    /****************************************************<?
                    * Name: TagCloudInc
                    * Version 1.1
                    * Desc: Displays how frequently the members of a wordlist appear in the site's content in a "tag cloud"
                    * created by Paul Paulousek [email protected]
                    * date July, 21. 2006
                    * based on tagcloud of Marc Hinse, [email protected], www.modxcms.de
                    * Version: 1.1.
                    *
                    * Usage: [[TagCloudInc?parent=`1,3,5,6,7,14`&min=`3`&landing=`12`]]
                    * Parameters: 
                    * 	parent: comma separated list of the folders that contain 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)
                    *       if a chunk named "cloudwords" exists, the snippet will take the content of it for building the cloud
                    *      the chunk must contain a comma-separated list of words.
                    * ***************************************************/
                    
                    $parent = isset($parent)? $parent : "0"; 
                    $min = isset($min)? $min : "2";
                    $landing = isset($landing)? $landing : "[~[*id*]~]";
                    
                    $include =  $modx->getChunk('cloudwords');
                    $include = explode(",",$include);
                    //try to get a Chunk for the include-words
                    if (sizeof($include)<2) {
                    $include = array('blog','method','edit','content','design','links','quickedit','MODx','customize'); 
                    //include list (sample, put in your words here)
                    }
                    //try to get a Chunk for the include-words
                    if (!isset($include)) {
                    $include = array('blog','method','edit','content','design','links','quickedit','MODx','customize'); 
                    }
                    //include list (sample, put in your words here)
                    $zeichen = array(',','.',':');		//array of chars to be deleted
                    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
                    
                    $words=array();
                    	foreach($include as $incword) {
                    	$wert = substr_count($content,$incword);
                    		if($wert>$min) { 	//look if the word counts the required minimum and is in the include list 
                    			$words[$incword] = $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;

                    Changes:
                    The site-content is not exploded into an array anymore, substr_count is used instead.
                    The loop does not go thru all the words as in the previous version, but just thru the words in the include-list.
                    The include-list can also be stored in a chunk named "cloudwords" (as a comma separated list), so that you do not have to edit the snippet’s source if you want to change your include-list.
                    If you think it’s worth to be put into the repository, please do so yourself or just let me know.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Very cool and very nice addition ppaul. Thanks.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me