Hi there do you know what is the best way to program a good Tag Cloud? Also where I can find info online regarding programing a Tag Cloud ? thanks anybody for your help
I have seen it done a few ways, the way I did it probably not the most efficient way, but it works well enough. I have two Tables linked by one key. The Articles Table and the and the Tags Table. The Articles all have a unique ID and all of the articles. The Tags Table has its unique ID, the articleID and the actual Tag. The hardest part is usually the query, I'll show you what I did: SELECT TOP 35 COUNT(Tag) as TagCount, Tag FROM tblMagazineArticleTags GROUP BY Tag ORDER BY NEWID() Code (markup): This is using a SQL Server Database, if you are using MySQL change ORDER BY NEWID() to ORDER BY RAND(). And use LIMIT 0, 35 instead of TOP 35. Generally Tag Clouds are in alphabetical order, for simplicity I sorted my DataTable on the front end (even though I am a firm believer in 'whatever the back-end can do, the back-end should do.' Anyway, that is the basic stuff, getting into the sizing gets fun too. I summed up all of the totals and found the standard deviation so that most of them were medium sized and few were extra small and extra large. A way to simplify that is to just choose a size based on how many occurances. if (i > 10) return "largestTag"; if (i > 5) return "largerTag"; if (i > 3) return "mediumTag"; if (i > 1) return "smallTag"; return "smallestTag"; Code (markup): Where this is assigning the CSS class based on the number of occurrences of each of these. I am kind of rushing the post and generalizing, if you have any more specific questions I can answer for you feel free to ask.
Hi dgxshiny , thanks for your respond I appreciate your help. I actually not a programmer, I want to get some ideas how should tag clouds works so I can tell a programmer how I want it to be done. can u give more info about how you sorted the tags, and other options that you have. if you can try to make it more easy to understand for someone without a programming background. How would you customize a tag cloud for popular tags ? Does your cloud will be full with the largest font size. Did I understand it right ? if so, how would you display popular tags ?
I chose 35 random tags and sorted them in alphabetical order (it is common practice, I have only seen a few that are not in order). With 35 random tags in alphabetical order I calculated the display size of each one based on the popularity. If a tag was only used a few times, I would display in font-size extra small, if it were used an average amount of times I used a standard font size, and then if it were used many times (most popular) i used an extra large font size. You can specify the sizes to include in-between sizes as well. In regards to how to sort them, the best option (to get technical) would be to create a temporary table and fill it with 35 random tags, then return the result of that temporary table in alphabetical order.