We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    Quote from: davidm at Jul 05, 2006, 07:24 PM

    On a completely different line of thinking, I was wondering how hard it would be to have the snippet look into TVs (don’t shoot me Marc tongue ) ?

    That is actually what we did for the tag cloud used on the repository. I will put out the code for a tv tag cloud sometime later today next week.
      • 6726
      • 7,075 Posts
      This is VERY cool Kyle, I just happen to have a need for this on a project I am working on smiley
        .: COO - Commerce Guys - Community Driven Innovation :.


        MODx est l'outil id
        • 17883
        • 1,039 Posts
        ... I would be surprised if Marc had not considered this

        I considered this, but didn´t find time for a db-based solution. Since caching works fine in modx I think it´s enough to call the snipped cached ( [[...]]) , so it will not render everytime.

        Marc
          • 34162
          • 1 Posts
          Cooool snippet! kiss
          But I find it difficult to set up the exclude list. It’s getting extremely large.
          My current top-three in my cloud (based on the demo-site) are "you","up" and "with"
          Why not doing it the other way round: Using an INCLUDE list of words which might be of semantic relevance in the site?
          This is, of course, not the same as using categories or manual tagging. It just makes it easier to control which words are making sense in a tag cloud for a given site.




            • 34162
            • 1 Posts
            This is not the best way to do it in terms of performance and efficiency, but it is the way of minimal changes to Marc’s version.
            So if anyone wants to do it like I do (predefining the words which can appear in the cloud, instead of creating a huge exclude-list)
            here’s the code:
            /****************************************************<?
            * Name: TagcloudInc
            * Version 1.0
            * Desc: Displays how frequently the members of a wordlist appear in the site's content as a "tag cloud"
            * created by Paul Paulousek [email protected]
            * date July, 12. 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)
            * ***************************************************/
            
            $parent = isset($parent)? $parent : "0"; 
            $min = isset($min)? $min : "2";
            $landing = isset($landing)? $landing : "[~[*id*]~]";
            
            
            $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
            $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,$include))) { 	//look if the word counts the required minimum and is in the include 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;

            Have fun, and thanks Marc for the original! smiley
              • 6726
              • 7,075 Posts
              That’s pretty interresting variant ppaul, thanks for sharing I might have a use for it smiley
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 34162
                • 1 Posts
                I could rewrite it for better performance. If someone is interested: just let me know and I’ll do it.
                The site where I intend to use it is pretty small, so performance is not a big issue for me.
                But for larger sites it’s a different matter, of course.
                  • 17883
                  • 1,039 Posts
                  Hi ppaul,

                  I could rewrite it for better performance. If someone is interested: just let me know and I’ll do it.

                  Perhaps wait for Kyle´s solution, because I think...

                  That is actually what we did for the tag cloud used on the repository. I will put out the code for a tv tag cloud sometime later today next week.

                  it´s better because otherwise there is a doubled work wink

                  After my site is (was) growing, I have to second that an exlude list is hard to handle. But my intention was not to "cheat" the list. And with tagging/only including you always will... somehow wink

                  For better performance it perhaps would be cool to store the results/links in an extra table and run this storing once a day (or better at the on store document event) with a plugin.

                  Go on guys smiley

                  Marc
                    • 34162
                    • 1 Posts
                    Quote from: MadeMyDay at Jul 12, 2006, 04:00 PM

                    But my intention was not to "cheat" the list. And with tagging/only including you always will... somehow wink
                    I do not think that an including list is "cheating", since it only uses real content, not deliberately or ""cheatingly" set tags or categories.
                    For the rest: of course we’ll wait, and a database-solution would of course be better. (I thought of the FULL TEXT feature of MySQL).
                    And my guess is: kyle’s work will not use an exclude-list but something similar to an include list wink

                    regards, waiting for kyle...
                      • 6726
                      • 7,075 Posts
                      @Marc : Kyle had mentionned doing some modification on TagCloud for the repository that would be made available soon (the ability to search TVs was mentionned laugh ) Any news ?
                        .: COO - Commerce Guys - Community Driven Innovation :.


                        MODx est l&#39;outil id