The TAG Cloud

Well I have never been accused of being an expert developer, (but I did stay at a HolidayInnExpress last night…)

For some time now I have been asked about some modifications made to get the TAGCloud to be site recursive. And with the help of some friends Mike of K2.com fame and fortune and Holly my general go to girl, we managed to get the TAGCloud webpart found on codeplex to do some cool extra stuff. Namely be recursive to return tags from all sub websites in the site collection, something that we needed for our internal MOSS implementation.

The basics of the webpart is to look for all items contained in a sitecolumn named tags (the column name is configurable) and display then in a webpart so you can click on each item and have I return all items that have been tagged with that tag.

In this tag web part they get the context of where the web part and then calls (GetListItemsFromWeb for that site)

SPWeb mySite = SPControl.GetContextWeb(Context);

GetListItemsFromWeb(TagName, ref al, mySite);

In the original version it stops there. But in our case we needed to figure out how to get the other sites in our collection. We experimented with several options but decided on leveraging GetSubwebsForCurrentUser as we found that it did the job the best.

We used it as follows

foreach (SPWeb subWeb in mySite.GetSubwebsForCurrentUser())

{

GetListItemsFromWeb(TagName, ref al, subWeb); mySite.GetSubwebsForCurrentUser().Count > 0

}
I am attaching the full code base with these changes (obviously there is more to it but that's the gist of what we did)

There are probably several other ways to do this, and maybe even some better ones, but it is working great for us. Let me know what you think or if I am missing something. Feedback is always a good thing good or bad.

For now here are some good links for this

TAG Cloud Discussion Threads

http://www.codeplex.com/Thread/View.aspx?ProjectName=CKS&ThreadId=15094

TAG Cloud Releases

http://www.codeplex.com/CKS/Release/ProjectReleases.aspx?ReleaseId=4820

I feel that I must point out how AWESOME Codeplex is. I have setup a RSS feed for Codeplex and check it all the time. There is so much up there that is useful and can help you right away by implementing it, or help you by giving you examples. With some minor tweaks we implemented the TAGCloud and the Faceted search for our internal MOSS portals, and have been very very happy.

In the code check out the SpTagBrowser.CS and SPTagCloud.CS as these are the primary places we changed the code.


Posted Sun, Jan 27 2008 10:52 PM by chrisg

Comments

Stoneford wrote re: The TAG Cloud
on Mon, Jan 28 2008 8:12 AM

Hi Chris,

Thanks for posting the codebase! I really appreciate it :-)

cheers,

Jaap Steinvoorte

Stoneford wrote re: The TAG Cloud
on Sun, Feb 3 2008 4:57 PM

Hi Chris,

Can you pllease help me out? I deployed the updated Tag Cloud (thanks to your modifications and help) but it seems the subwebs are not iterated. Although I know that there are tags (in a subweb the Tag Cloud displays the available tags) I placed a Tag Cloud web part on a site with subsites. But I don't see the tags appear. Is there something I'm missing?

Jaap