*** UPDATE 25.04.06: New version attached ***
Hi there,
some say they are useless, some say they are evil, but why not make them usable with modx
What is a tag cloud? A
tag cloud is a list of tags that are linked to an overview or to the search (like in this case). The sense is imho to give a visitor a qucik overview of what is the site all about. The words (tags) are counted and weighted - the more they occur in the content, the bigger the link is displayed. There are two possibilities to achieve that:
1. For every document you publish, you define some tags (like "modx, css, ajax, cms"). These tags are then counted and weighted
2. Automatically: All words are counted and weighted (with the possibility to filter out common words)
I chosed the second alternative, because the first one seems imho to be a "self fulfilling prophecy", because your tagging never will be neutral and you will influence the cloud by adding tags to your documents that don´t match that much - just to get the words in there which you like.
SnippetThe snippet is called like:
[[tagcloud?parent=`1,3,5,6,7,14`&min=`3`&landing=`12`]]
parent: The folders where your to be counted documents are in. Note: There is no multilevel yet, so set every folder where docs are in. [ 0 ]
min: Minimum of occurrences for a single word to be displayed [2]
landing: The id of your search result page. If you don´t have one, create a doc with content:
[!FlexSearchForm?FSF_showResults=`1` &FSF_showForm=`0`!]
At the top of the snippet code you see an array with the filter words, which shouldn´t be displayed:
$exclude = array('',' ',' ',' ','and','a','-','—','–','the','—','to','.',':',',','in'); //exclude list
here you put in common words which shouldn´t be displayed/linked. This is necessary, because otherwise you have a lot of counts for "in", "the" and so on. Just extend it like you wish.
The rest is also commented in the code.
The output is put in a div box with class "tagcloud", you can change that also in the code.
Additionally the tags are linked to the search, because they have to be linked somewhere

Example of the snippet (on the bottom right)
Marc