Alert This post is over a year old, some of this information may be out of date.

Hiding the Social Actions (Follow / Share) from the Document Libraries in SharePoint 2013

SharePoint 2013 got very social, everything can be tagged, followed, shared. But these new social features require some user adoption, and it could be that your client does not want to have this functionality.

This is exactly what a client of us requested, they did not want to have the Follow and Share actions on their site and document libraries.

Hiding the Site Social Actions

First of all, hiding the follow and share actions on your site is not that difficult. They can be hidden by some custom CSS.

Show image Social Ribbon Actions
Social Ribbon Actions

Hiding Document Library Callout Actions

Hiding the callout actions in the document library is a bit more difficult, because the links do not have a specific ID or Class defined.

Show image Document Library Callout Standard Actions
Document Library Callout Standard Actions

The trick is to override the default callout that is generated for the document libraries. This is also what SharePoint does, they are overriding the default callout to add the Follow action in the callout.

To override the default document library callouts and hide the Follow action, you can use the following code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
var registerOverrideToHideSocialActions = function(id) {
  var socialactionsOverridePostRenderCtx = {};
  socialactionsOverridePostRenderCtx.BaseViewID = 'Callout';
  socialactionsOverridePostRenderCtx.ListTemplateType = id;
  socialactionsOverridePostRenderCtx.Templates = {};
  socialactionsOverridePostRenderCtx.Templates.Footer = function(renderCtx) {
    var  renderECB;
    if (typeof(isSharedWithMeView) === 'undefined' '' isSharedWithMeView === null) {
      renderECB = true;
    } else {
      var viewCtx = getViewCtxFromCalloutCtx(renderCtx);
      renderECB = !isSharedWithMeView(viewCtx);
    }
    // By setting a null value as 2nd parameter, we do not specify additional callout actions.
    return CalloutRenderCustomFooterTemplate(renderCtx, null, renderECB);
  };
  SPClientTemplates.TemplateManager.RegisterTemplateOverrides( socialactionsOverridePostRenderCtx);
}
// Hide actions for default Document Libraries
registerOverrideToHideSocialActions (101);
// Hide actions for the document library on your My Site
registerOverrideToHideSocialActions (700);

The registerOverrideToHideSocialActions function is for two lists (101 and 700). ID 101 is a standard Document Library, and ID 700 is the My Documents Library on you My Site (SkyDrive Pro).

For hiding the Share action I created a custom footer template function (CalloutOnPostRenderCustomTemplate). The code for this function looks like this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
function CalloutOnPostRenderCustomTemplate(renderCtx, calloutActionMenu) {
  var listItem = renderCtx.CurrentItem;
  var openText = GetCallOutOpenText(listItem, renderCtx);

  calloutActionMenu.addAction(new CalloutAction({
    text: openText,
    onClickCallback: function(calloutActionClickEvent, calloutAction) {
      CalloutAction_Open_OnClick(calloutActionClickEvent, calloutAction, renderCtx);
    }
  }));
}

Download the full JavaScript code here: Hide the Follow and Share Actions.

_Note: Best is to add this code at the bottom of you master page. This can be either in a script block or in a script file itself (your choice, but a script file is always cleaner). _

Result

The result looks like this:

Show image Callout without Follow and Share Actions
Callout without Follow and Share Actions

Changes

14/02/2013

You also have a Site Level Feature called Following Content to disable the Follow functionality. When you want to hide the Share action, you will still need to override the default callout.

Comments

Back to top