We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21056
    • 327 Posts
    This is an auto-generated topic for TvTagCloud 2.2-release by ncrossland.

    Brief Description:

    Displays the tags from set of documents in a "tag cloud" or list.
    REQUIRED PARAMETERS

    parent: folder that contains the documents which are to be counted. Can take a comma separated list of parents, like Ditto does.

    tvTags: the template variable that has the tags

    OPTIONAL PARAMETERS

    depth: the number of levels down we should search for child documents

    days: the number of days to look back over to find tags. Leave as 0 for all time

    min: minimum number of tag occurances for tag to show, 0 for all

    sort: how should the results be ordered? By default they will be sorted by document ID. Values can be:
    asc - tag alphabetical
    dec - tag reverse alpgabetical
    numasc - tag count ascending
    numdesc - tag count descending
    random - random order

    landing: id of document to display ditto listings

    tagDelim: delimiter between tags in TV

    displayType: [[cloud | list | custom]] output as a tag cloud, unordered list, or custom output. If custom output, specify a chunk name via customDisplayChunk

    customDisplayChunk: chunk name containing HTML when displayType = custom. Uses the following placeholders: [[+class+]] [[+landing+]] [[+qs_seperator+]] [[+url_param+]] [[+tag+]] [[+urlencoded_tag+]] [[+tooltip+]] [[+count+]] [[+bracketed_count+]]

    showCount: if you want the number of occurances to be displayed set to 1

    caseSensitive: if you want tag duplicate removal to be case sensitive set to 1

    steps: comma separated list of the numeric intervals to determine the size of the tag class

    styles: comma separated list of class names that will be applied to each of the size intervals in "steps"

    tooltip: Template for the tooltip that will appear as the title attribute for each tag link. Takes placeholders [[+count+]] and
    [[+tag+]] which will be replaced with appropriate values

    dittoID: Id of the Ditto instance which should display the selected tag (if there is more than one Ditto call on landing page)

    limit: restrict the number of tags to display

    exclude: list of tags you don't want to appear in the output (separated by tagDelim - a comma by default)

    promote: list of tags you want to appear first in the output (separated by tagDelim - a comma by default)

    demote: list of tags you want to appear last in the output (separated by tagDelim - a comma by default)

    extraTags: list of extra tags you want to appear, even if they're not detected in the pages (separated by tagDelim - a comma by default)

    currentClass: class name to apply to the tag which is currently being filtered on

    urlParam: name of the URL parameter used when generating URLs or detecting filtering
      Author: ManagerManager plugin - customise your ModX manager interface

      Rckt - web development, Sheffield, UK
      • 22164
      • 50 Posts
      Thanks for this great snippet!

      Question: how can I get rel="nofollow" added to the links?

      thanks

      Oliver
        Happy to have left Back Pain | Sciatica behind.
        • 17802
        • 190 Posts
        Yes, thanks a lot! Works like a charm laugh
        Oliver: I think you need to use a custom display chunk for that. Or find the output part of the snippet (somewhere near the bottom of the script) and add the nofollow attribute there. Caution: this is not a best practice, because it will break when upgrading the snippet.
          Thanks for MODx - I love it!
          • 8883
          • 59 Posts
          Thanks for sharing the Snippet.
          Unfortunately Umlauts were not correctly converted when caseSensitive is activated.

          on line 209:
          $tag = ($caseSensitive) ? $tag : strtolower($tag);


          Instead of
          strtolower() 

          use
          mb_strtolower()


          Maybe not the best solution, but it worked for me (in combination of UTF-8 without BOM).

          By the way is it possible to add a feature of merging multiple TVs in ONE cloud/list?
          Like
          &tvTags=`tv1,tv2`

          will return one cloud consisting of this different sources.

          Bye
            • 4803
            • 20 Posts
            Had a problem with the minimums not working so I changed this part of it. I didn’t save the original version, but it
            shouldn’t be too hard to figure out where I made the changes. Before I made the changes, the code wouldn’t properly loop through the list of tags to check minimums.
            // Now we've totalled up how often each word appears, determine what style we should apply
            foreach ($tags as $tag => $data) {
            	
                    $output .= "<p>$tag - ".$data['count']." - Minimum: $min </p>";
            	// if this tag has less than the minimum required count, remove it
            	if ($min > 0 && $data['count'] < $min) {
            		unset($tags[$tag]);
            	} else {
            	
            	     $chosen_style = 0;	// a default style
                         $step = $data['count'] == 0 ? 1 : 100 / $data['count']; // get percentage
            	
            	    for ($i=0;$i<count($steps);$i++) {
            	     	if ($step <= $steps[$i]) {
            	     		     $tags[$tag]['style'] = $styles[$i];
            			     break;
            		  }
            	     }	
                 }
            
            // Left in for debugging	
            /*	
                    echo "-------------- $tag \n";
            	echo "total tag_count: $tag_count \n";
            	echo "this tag count: ".$data['count']." \n";
            	echo "step: $step \n";
            	echo "chosen_style: ".$tags[$tag]['style']." \n";
            // */
            			
            }

              • 19566
              • 1 Posts
              One inconsistency I noticed in the snippet:

              The currentClass parameter is not applied to the current tag link when &displayType is set to ’list’ (as opposed to ’cloud’).

              This really threw me off when trying to use this until I looked deeper in the snippet code. Attached is an updated bit of code to replace the beginning of the "output" section of the snippet. Basically, just add class="[+class+]" to the link.
              /* ------------- Output ------------- */
              
              
              
              switch ($displayType) {
              		case 'cloud': 
              			$start = '<div class="tagcloud">';
              			$tpl = '<span><a class="[+class+]" href="[~[+landing+]~][+qs_seperator+][+url_param+]=[+urlencoded_tag+]" title="Click for items tagged [+tag+] [+bracketed_count+]">[+tag+] [+bracketed_count+]</a></span>'."\r\n";
              			$end =  '</div>';
              		break;
              		
              		case 'list':
              			$start = '<ul>';
              			$tpl = '<li><a href="[~[+landing+]~][+qs_seperator+][+url_param+]=[+urlencoded_tag+]" title="Click for items tagged [+tag+] [+bracketed_count+]" class="[+class+]">[+tag+] [+bracketed_count+]</a></li>'."\r\n";
              			$end =  '</ul>';
              		break;
              		
              		case 'custom':
              			$start = '';
              			$tpl = $modx->getChunk($customDisplayChunk);
              			$end = '';
              		break;
              }
              

                • 13428 ☆ A M B ☆
                • 1,031 Posts
                Two small things:

                First a a bug (maybe in this version too): the numasc/numdesc sort did not work for me (in 2.1.4):

                It has to be used a custom sort for this (lines 268+):
                    case 'numasc':
                        uasort($tags, 'compareTagCounts'); // sort by value asc
                        break;
                    case 'numdesc':
                        uasort($tags, 'compareTagCounts'); // sort by value desc
                        $tags = array_reverse($tags);
                        break;
                

                and
                /* ---------------- compareTagCounts ---------------- */
                if (!function_exists('compareTagCounts')) {
                    function compareTagCounts($a, $b) {
                        if ($a['count'] == $b['count']) {
                            return ($a['name'] < $b['name']) ? - 1 : 1;
                        }
                        return ($a['count'] < $b['count']) ? - 1 : 1;
                    }
                }
                


                Second a sort enhancement for locale string sorting (lines 260+):
                setlocale(LC_ALL, 'de_DE.UTF-8');
                switch ($sort) {
                    case 'asc':
                        ksort($tags, SORT_LOCALE_STRING); //sort them alphabetically
                        break;
                    case 'desc':
                        krsort($tags, SORT_LOCALE_STRING); //sort them reverse alphabetically
                        break;
                

                The locale should be set by parameter.
                  • 4036
                  • 239 Posts
                  Hi!

                  I have problem with encoding the letters.

                  [!TvTagCloud? &parent=`0` &landing=`17` &tvTags=`documentTags` &tagDelim=`, ` &sort=`asc`!]


                  TvTagCloud 2.2
                    Портфолио - http://wowstudio.pro
                    • 22164
                    • 50 Posts
                    I am using this on a German language site now and would like to see the words capitalized. How can I do that?

                    In german it is customary to have nouns written with beginning capitals.

                    tnx

                    Oliver
                      Happy to have left Back Pain | Sciatica behind.
                      • 332
                      • 23 Posts
                      Hi, I am having trouble getting this Snippet to work, any help would be appreciated. I cannot get any output out of the TVTagCloud Snippet. I have made sure twice that the php snippet code is correct.

                      My calls:

                      [!TvTagCloud? &parent=`83` &landing=`107` &tvTags=`tagLinks` &depth=`2` &displayType=`list` &dittoID=`dlp` !]

                      and on the landing page (id 107), I have:

                      [!Ditto? &parents=`83` &extenders=`tagging` &tagData=`tagLinks` &tagDelimiter=`,` &id=`dlp` !]

                      However, the page that has the TVTagCloud snippet is not rendering any output. What am I doing wrong??
                      Thanks in advance!!