1

I'm trying to add a button to the ribbon, in the same place the default "I Like It" and "Tags & Notes" buttons are located. I the elements.xml file for this feature (SocialRibbonControl) and tried copying it, but for some reason it won't work and I'm not sure why. Has anyone ever done this?

Here's the code:

<CustomAction
    Id="Ribbon.Documents.AppendSocialRibbonControl"
    Location="CommandUI.Ribbon"
    Title="$Resources:spscore,SocialRibbonControl_SocialRibbonControlAction_Text"
    Sequence="10">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Groups._children">
          <Group Id="Ribbon.Documents.TagsAndNotes"
                 Sequence="80"
                 Command="TagsAndNotesGroup"
                 Description=""
                 Title="$Resources:spscore,SocialRibbonControl_SocialRibbonControlAction_Text"
                 Template="Ribbon.Templates.Flexible2">
            <Controls Id="Ribbon.Documents.TagsAndNotes.Controls">
              <Button
                Id="Ribbon.Documents.TagsAndNotes.FavoriteSite"
                Sequence="1000"
                Alt="Fav"
                        Command="ILikeIt"
                        Image16by16="/_layouts/images/QuickTagILikeIt_16.png"
                        Image32by32="/_layouts/images/QuickTagILikeIt_32.png"
                        LabelText="Fav"
                        ToolTipTitle="fav"
                        ToolTipDescription="fav"
                TemplateAlias="o1"/>
            </Controls>
          </Group>
        </CommandUIDefinition>
      </CommandUIDefinitions>
    </CommandUIExtension>
  </CustomAction>

Update I forgot to mention that this is all within a sandboxed solution.

Update 2 Damn you, sandbox! The GlobalSiteLink3 is a farm scoped delegate control. And since you can't deploy farm based features in the sandbox, you can't overwrite it...

3
  • what issue exactly you're getting there? Commented Jun 4, 2012 at 8:57
  • do you want to replace existing ones and add yours? or do you just want to add your button along with "I Like It" and "Tags & Notes" ? Commented Jun 4, 2012 at 9:01
  • I want to add my own, the SharePoint buttons should be there if the user wants them (activates the feature), but are optional.
    – Jasper
    Commented Jun 4, 2012 at 10:03

2 Answers 2

3

AFAIK the "i like it" controls are not part of the ribbon?

If you want to replace the controls, you can create a custom control that inherits from SocialNotificationBase and render your own content in the OnLoad control

public class ReitanSocialNotification : SocialNotificationBase
{
    public ReitanSocialNotification()
    {
        base.NotificationMessageFormat = "<span style='padding:3px;'>{0}</span>";
    }

    protected override void OnLoad(EventArgs e)
    {
        if (this.Visible)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("<div class='ms-mini-socialNotif-Container'>");
            builder.Append("<ul class='customSocial'>");

            // NOTE: we cant check if I LIKE IT feature is enabled since SocialItemType is internal! :(
            builder.AppendFormat("<li class=\"customQuickTag\"><a class='ms-mini-socialNotif' id='AddQuickTag_{0}' ", this.ClientID);
            builder.AppendFormat(" href='javascript:;' onclick='{0}_AddQuickTag();' ",this.ClientID);
            builder.Append(" title=\"Your title goes here.\">");
            builder.Append("I like it!</a></li>");

            builder.AppendFormat("<li class=\"customTagNotes\"><a class='ms-mini-socialNotif' id='TagsAndNotes_{0}'", this.ClientID);
            builder.Append(" href='javascript:;' onclick=\"SafeRunFunction(function() { TagDialogOpener.Open('http:\u002f\u002fintranet\u002fsites\u002ftest\u002f_catalogs\u002flt\u002fForms\u002fAllItems.aspx', document.title, '0'); }, 'SocialData.js', 'TagDialogOpener');\" ");
            builder.AppendFormat(" onmouseover='{0}_GetSocialNotification();' title='Your title goes here.' >", this.ClientID);
            builder.Append("Tags and notes</a></li>");
            builder.Append("</ul>");
            builder.Append("</div>");
            this.Controls.Add(new LiteralControl(builder.ToString()));
            base.OnLoad(e);
        }

    }
}

You can then (depending on what master you are using) insert the control in the DelegateControl GlobalSiteLink3 with a low sequence to override the existing control. More on delegate controls.

6
  • Hi Anders, they're not really in tab group, but they are in the same area as the site title and stuff. I don't know a better name as ribbon for that :) Thanks for the pointer to GlobalSitelink3 though, I'll take a look at that.
    – Jasper
    Commented Jun 4, 2012 at 10:05
  • Weird. I think the delegate is indeed what I need, but somehow it won't work. For testing I copied the code from the SocialRibbonControl feature (OOTB), the delegate elements.xml into my own feature. Activated it, but nothing happens. Checked ULS, nothing. Tried including a file, that get's deployed as expected so the feature activation is working.
    – Jasper
    Commented Jun 4, 2012 at 11:25
  • I myself didn't realize that a Delegate control would suffice. Commented Jun 4, 2012 at 12:57
  • did you set sequence lower than OOB? You can check OOB sequence in the OOB feature element manifest. Commented Jun 4, 2012 at 13:02
  • Yeah I did. The problem is that the GlobalSiteLink3 delegate is scoped to the Farm level. And from within the sandbox, deploying farm based features is impossible. So it seems this just isn't possible in the sandbox :( I don't understand why they chose to scope it like this.
    – Jasper
    Commented Jun 4, 2012 at 14:38
0

Final answer: in Office 365 it's not possible because you cannot use GlobalSiteLink3 as it is farm scoped and you cannot deploy any farm scoped parts in 365. Not without deploying a custom masterpage that is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.