Question

I am new to the tag cloud. I am about to implement Tag Cloud feature in my project. In order to do that, I should have some knowledge about it. I just started learning it, got some theoretical idea of a tag cloud & what it is?

A tag cloud is a visual depiction of the tags(Topics) on a web site.

How does tagging work? Are there any rules for generating tags in a tag cloud?

Which JQuery plugin should I use? As s workaround I have searched the tag cloud plugins in JQuery site. I have found these.

Was it helpful?

Solution

A tag cloud is a collection of tags that are decidedly most popular based on the number of occurrences within your site. The size of each tag as it is displayed in the cloud is based on the popularity of that tag. There are many ways to implement this. Typically, css dictates the size of the font, which may be handled something like this:

Tags table:
id, tag

Article table:
id, title, body, etc

Tag relation table:
article_id, tag_id, user_id

So when users tag articles it adds the relation to the relation table using the user's id, the article id and the tag id. That way you log individual occurrences of tags on articles, and who tagged them. A unit of measure, in other words.

A Tag Cloud fetches a collection of tags - typically tags with at least 1 use - and probably should be otherwise relatively random. So your fetch query may result in something like:

tag, score (algorithm based on the number of occurrences and whatever factors you choose)

cool : 2
cars : 5
funny : 4
hot : 1
ugly : 7

You then use the score of your tag to apply a css class. You COULD let it be infinite and grow out of control, but it is better to set bounds. So we give a 1 - 10 option. In css you could define a class for each score:

.score-1{
    font-size: 1em;
}

.score-2{
    font-size:1.1em;
}

.score-3{
    font-size:1.2em;
    font-weight:bold;
    color:#ff6600;
}

//etc.

and serve the html like:

<a href="tags.php?tag=15" class="score-2">Cool</a>
<a href="tags.php?tag=10" class="score-7">Ugly</a>
<a href="tags.php?tag=3" class="score-5">Cars</a>
<a href="tags.php?tag=4" class="score-1">Hot</a>
<a href="tags.php?tag=6" class="score-4">Funny</a>

Aside this, jQuery doesn't necessarily have anything to do with a tag cloud. But there may be plugins that somehow do, so go for it if you find them.

I should clarify the "score" in this example assumes you have an algorithm that takes the occurrences and - based on any number of your own criteria, assigns a final score value of 1 - 10. NOT necessarily using the raw count as a score. Rocket mentions the tag cloud being the TOP tags on a site - and this could be clarified as a top RANGE on a website. otherwise you could end up with a tag cloud where all the tags are giant and the same size. I had a site that lingered on the top 10 tags all having the same number of occurrences give or take a couple points for weeks. You can look into standard deviation to factor scores. I tend to use that a lot to avoid spamming. Also, time since last used, credibility of the users using the tags, etc.

If you have any particular questions, let me know and I may update.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top