Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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...

share|improve this question
    
what issue exactly you're getting there? –  Falak Mahmood Jun 4 '12 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" ? –  Falak Mahmood Jun 4 '12 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 Jun 4 '12 at 10:03
add comment

2 Answers

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.

share|improve this answer
    
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 Jun 4 '12 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 Jun 4 '12 at 11:25
    
I myself didn't realize that a Delegate control would suffice. –  Falak Mahmood Jun 4 '12 at 12:57
    
did you set sequence lower than OOB? You can check OOB sequence in the OOB feature element manifest. –  Anders Rask Jun 4 '12 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 Jun 4 '12 at 14:38
show 1 more comment
up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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