Azure / Office 365 / SharePoint Development / Search

Take your SharePoint social features to the next level with “I like it” and “Tags” counters: Part 3

April 05, 2012

In the previous parts I showed you how to retrieve all tags for a specific page/item.

In this part (the last one) I will show you how you can integrate these tags into your design.

This will be the final result:

Social Tags Results

Social Tags Results

User Control

You have various possibilities to show these tag results on your page. One of these possibilities, which I am going to explain, is a user control.

The advantage of creating an user control is that you can add the control into your master page, and so it will be displayed on all the pages that uses this master page.

My user control looks like this:

And this is the content of the code behind:

Master Page

When you deploy your (or mine, can be downloaded at the bottom) user control to SharePoint, you need to reference it in your master page.

Step 1

Open your master page in SharePoint Designer and add the user control reference at the top of the master page.

Step 2

Find the place where you want to add the user control.

In my example I added a new table column next to the social data buttons. You can do this by doing a search for the following class s4-socialdata-notif and change the HTML to this:

HTML Code for Social Tags Location

HTML Code for Social Tags Location



Save and publish your master page. When you now go to a SharePoint page, you should have the following result.

Social Tags Result

Social Tags Result

Download

Social Tagging Control

Comments

  • Jim

    Mr. Struyf:

    This solution works great with general pages – nice work. I seem to have difficulty in making the code count tags for “Posts” types – specifically, I am looking for a way to count the “I like it” tags for Post items / pages in a blog. Any ideas? Thank you.

    • estruyf

      Jim,

      I just checked why it does not work for blog posts. The problem arises because there an incorrect URL is used. A blog post URL looks like this: http://sp2010/Lists/Posts/Post.aspx?ID=1, but when I checked it on the “Manage Social Tags and Notes” page. It references a different URL: http://sp2010/Lists/Posts/ViewPost.aspx?ID=1.

      To quickly solve this, you could do a check if the URL contains Post.aspx and replace it with ViewPost.aspx.

      Regards,
      EStruyf

  • Jay

    This is great, however I’m using this method to try to return tags through a webservice, and no matter what I do, it always returns no results even though there are clearly tags associated with the page. Any idea why this would happen? Thanks!!

    • Jay,

      The problem is that the tags are added to a URL, so you need to use the exact same URL in order to retrieve the tags.

      Did the method invoke work? Are you getting any errors?

      Regards,
      Elio

  • Daniela F

    Hi Elio,

    First of all, thank you for this solution! I am working with SharePoint 2010 and my client wanted to have more social interaction on the articles they publish, so this is what I am looking for to show the counts of all the Likes by page! The only problem I have, after the deployment of your solution, is that, even if it is counting the Likes, it keeps “Working” when you open the Tags and Notes window, kind of if it kept loading. Now I cannot add more tags (and eventually that pop up crashes).

    Do you have any idea why this could be happening?

    Thanks in advance!