Topic: [SNIPPET] Tag cloud  (Read 26917 times)

Pages: [1] 2 3   Go Down

#1: 19-Apr-2006, 03:12 AM

Moderators

MadeMyDay
Posts: 973

WWW
*** 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 Wink

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.

Snippet

The snippet is called like:

Code:
[[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:

Code:
[!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:

Code:
$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 Wink


Example of the snippet
(on the bottom right)

Marc

* tagcloud.snippet.txt (2.83 KB - downloaded 778 times.)
« Last Edit: 25-Apr-2006, 03:39 AM by MadeMyDay »

#2: 19-Apr-2006, 03:51 AM

Administrator

zi
MODx Special Forces /
Posts: 3,721

Peace Be Onto You

WWW
Great Snippet man!

You made my day! Grin

Thanks for sharing,

regards,

zi

#3: 19-Apr-2006, 04:13 AM

Coding Team

garryn
Posts: 1,450

WWW
How cool is that! Thanks Marc for a great snippet Smiley

#4: 19-Apr-2006, 06:21 AM

Marketing & Design Team

davidm
Former MODx evangelist
Posts: 7,077

The best way to predict the future is to invent it

WWW
Now that's something which will definetly be attractive to power bloggers... and will do a lot to help manage complex content !

Thanks a lot for this one Grin

.: COO - Commerce Guys - Community Driven Innovation :.


MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

#5: 19-Apr-2006, 06:37 AM

Moderators

MadeMyDay
Posts: 973

WWW
Thanks everyone Smiley

Quote
Now that's something which will definetly be attractive to power bloggers...

Wait until my trackback solution works Wink The "pinging" of other blogs works, but the "fetching" of trackbacks and converting into comments drives me nuts at the moment  Undecided But I´m on the way Wink

#6: 19-Apr-2006, 06:49 AM

Marketing & Design Team

davidm
Former MODx evangelist
Posts: 7,077

The best way to predict the future is to invent it

WWW
Trackbacks ? Well this is a VERY good news for blogging with MODx Grin !
.: COO - Commerce Guys - Community Driven Innovation :.


MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

#7: 19-Apr-2006, 07:21 AM

Moderators

MadeMyDay
Posts: 973

WWW
Hmm, just tried to trackback your blog, but it didn´t work. It doesn´t send a proper XML answer, don´t know why. For my Wordpress-Test-blog it works well as far I can see...  If I had known how complicated this kind of stuff is (for a non coder), I wouldn´t have started Cheesy Have to investigate this...

#8: 19-Apr-2006, 07:48 AM

Foundation

rthrash
Posts: 11,647

WWW
Marc, that is just too cool. Thanks so much for sharing. Smiley

Please help us help you when asking for assistance.
Ryan Thrash
MODx Co-Founder
MODx Revolution
Your Content, Your Way.

#9: 19-Apr-2006, 08:18 AM

Emeritus

aNoble
Posts: 680

WWW
Very cool. I've been thinking how cool it would be to do something like this for a while.

#10: 19-Apr-2006, 01:40 PM

Coding Team

kylej
Posts: 769

WWW
This is a very cool snippet. Great work.

Since we are talking about blog related snippets, has anyone made a calendar snippet that has the days highlighted for each post?  I can't seem to find one in the forums.  If not I am going to start working on one soon.

#11: 19-Apr-2006, 04:41 PM

Marketing & Design Team

davidm
Former MODx evangelist
Posts: 7,077

The best way to predict the future is to invent it

WWW
Hmm, just tried to trackback your blog, but it didn´t work. It doesn´t send a proper XML answer, don´t know why. For my Wordpress-Test-blog it works well as far I can see...  If I had known how complicated this kind of stuff is (for a non coder), I wouldn´t have started Cheesy Have to investigate this...

Yeah I have transfered my blog from Textpattern to Expression Engine, but I didn't have enough time to research this problem nor to fix it...  the problem is on my end with EE, I already had reports of this with system which work (DotClear, WordPress powered blogs unable to have trackback working...). Maybe I should also check the paranoid security settings @TextDrive, mod_security has been known to bug some TextDrive users...

« Last Edit: 19-Apr-2006, 04:43 PM by davidm »
.: COO - Commerce Guys - Community Driven Innovation :.


MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

#12: 21-Apr-2006, 07:52 PM

Coding Team

kylej
Posts: 769

WWW
Marc,
   I was testing this out on one of my sites, and noticed a little error in the code.  In the example calls you have the parameter &min, but in the code it looks for the parameter &max.

  Other than that it works great!

  Seeing max in there, I was wondering if you had thought about adding a paramter for max tags.  This way if you only wanted it to return a maximum of 20 tags you could set that.  Just a thought though.

Thanks for the snippet

Kyle

#13: 25-Apr-2006, 03:45 AM

Moderators

MadeMyDay
Posts: 973

WWW
Thanks Kyle for this catch!

I changed it and attached it at the first Posting.

Quote
Seeing max in there, I was wondering if you had thought about adding a paramter for max tags.  This way if you only wanted it to return a maximum of 20 tags you could set that.  Just a thought though.

max was just mixed up with min. The setting of a maximum tags would be no problem, but how to set it? The twenty most counted tags? Then it would be neccessary to sort by value, after that (un)sort back again, because otherwise you will have the most counted tags first, which wouldn´t look that good. Just explain what you mean and I will look what I can do Wink

Marc

#14: 25-Apr-2006, 09:24 AM

Coding Team

kylej
Posts: 769

WWW
Marc,
   I was thinking that if you wanted to show the top ten most counted tags you could set a paramter like max=10. 

  This would give you some more control as to how big of an area the entire cloud takes up, since you could limit the results.

  This isnt a necessary feature but just an addon that might be nice.

Kyle

#15: 25-Apr-2006, 09:36 AM

Moderators

MadeMyDay
Posts: 973

WWW
Hi Kyle,

this is a good idea. I will implement this the next days.

Marc

#16: 25-Apr-2006, 09:58 AM

Moderators

MadeMyDay
Posts: 973

WWW
erm, me again. How would you scale the tags then? In case of max=10 for example... The one with the least is scaled very small? In case the allocation is 4-4-4-4-4-4-5-5-5-6 there is not a big effect on the scale.  And what happens if there are more equal hits than 10 (in my example there are perhaps more words with 4 hits)? Show till the next lower level is reached?  I have to think ybout that, before i begin silly stuff Smiley

Marc

#17: 25-Apr-2006, 10:14 AM

Coding Team

kylej
Posts: 769

WWW
Those are some good points, and I'm not sure I have any good answers.

Rethinking on why I thought a max would be nice to have, I think it is not such a great idea.  Since you already have the ability to remove words you could get it to show ten reults that way if you wanted.  So really I don't think there is a need to add the new parameter, like you said the scaling would be difficult and how do you cut oof the list when multiple words could have the same count.

And the idea of a tag cloud is to show what your site is about so why limit it Wink

F.Y.I. I have modified the AjaxSearch snippet so that the tag cloud will work with it.  I will have the updated code for it out soon.
« Last Edit: 25-Apr-2006, 10:25 AM by kylej »

#18: 28-Apr-2006, 05:00 AM


lemerou
Posts: 52

I love MODx!

Great snippet idea !
Thanks

#19: 25-Jun-2006, 09:04 AM

tomtom
Posts: 8

Hi Marc, hi All together,
correct me if I am wrong. But I had a quick look at the tag snippet source and for me it looks like this snippet is generating the tags by parsing all current documents always live again and again. This could be a big performance problem when having a lot of pages, couldn't it?
I think we need an extra table for logging tag occurrence?
The simplest table structure could look like
Code:
tagged_word | content_id
.

Then we would need to hook into modx saving document to let the "tagged words" table to be automatically adjusted when saving a document.

I am completely new to modx, so I really don't have an idea how to realize this best.

Any suggestions and additional ideas welcome.

Regards,
Tom

#20: 5-Jul-2006, 07:24 PM

Marketing & Design Team

davidm
Former MODx evangelist
Posts: 7,077

The best way to predict the future is to invent it

WWW
I don't know about this snippet taking resources, did not notice it when I tried, but it would depend on the amount of content you have, wouldn't it ?
... I would be surprised if Marc had not considered this, but storing the tag occurences might speed things up... nice idea.

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 ) ?
« Last Edit: 5-Jul-2006, 07:27 PM by davidm »
.: COO - Commerce Guys - Community Driven Innovation :.


MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)
Pages: [1] 2 3   Go Up
0 Members and 1 Guest are viewing this topic.