none
Customize ribbon button in home page RRS feed

  • Question

  • Hello,

     I have a requirement to add a new button in sharepoint site home page ribbon. However I am able to find the solutions to customize the button for document library or list. I am not able to add a new button in home page. If you help me out, it would be great help.

    Appreciate your help.

    Wednesday, October 31, 2012 7:12 AM

Answers

  • Hi namsdn,

     I have come crossed the same problem. Please try to follow the below steps.

     Steps

    Step1 --> Create a empty project and under this create a module and new empty element.

    Step2 --> Copy the below sample code in the element.xml file

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
         Id="Ribbon.Sample"
         Location="CommandUI.Ribbon"
        >
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Tabs._children">
              <Tab
                Id="Ribbon.CustomTbSample"
                Title="Sample button"
                Description=""
                Sequence="501">
                <Scaling
                  Id="Ribbon.CustomTbSample.Scaling">
                  <MaxSize
                    Id="Ribbon.CustomTbSample.MaxSize"
                    GroupId="Ribbon.CustomTbSample.CustomGroupExample"
                    Size="OneLargeTwoMedium" Sequence="1"/>
                  <Scale
                    Id="Ribbon.CustomTbSample.Scaling.CustomTabScaling"
                    GroupId="Ribbon.CustomTbSample.CustomGroupExample"
                    Size="OneLargeTwoMedium" Sequence="2"/>
                </Scaling>
                <Groups Id="Ribbon.CustomTbSample.Groups">
                  <Group
                    Id="Ribbon.CustomTbSample.CustomGroupExample"
                    Description="CMS Group"

                    Sequence="56"
                    Template="Ribbon.Templates.CustomTemplateExample">
                    <Controls Id="Ribbon.CustomTbSample.CustomGroupExample.Controls">
                      <Button
                        Id="Ribbon.CustomTbSample.CustomGroupExample.CMS"
                        Command="CustomTabExample.CMS"
                        Sequence="15"
                        Description="Manage Sample"
                        LabelText="Manage Sample"
                        TemplateAlias="btnCMS"
                        Image16by16="/Style Library/images/Ribbon/Sample.png"
                        Image32by32="/Style Library/images/Ribbon/Sample.png"

                        />



                    </Controls>
                  </Group>
                </Groups>
              </Tab>
            </CommandUIDefinition>
            <CommandUIDefinition Location="Ribbon.Templates._children">
              <GroupTemplate Id="Ribbon.Templates.CustomTemplateExample">
                <Layout
                  Title="OneLargeTwoMedium"
                  LayoutTitle="OneLargeTwoMedium">
                  <Section Alignment="Top" Type="OneRow">
                    <Row>
                      <ControlRef DisplayMode="Large" TemplateAlias="btnCMS" />
                    </Row>
                  </Section>



                </Layout>
              </GroupTemplate>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
              Command="CustomTabExample.CMS"
              CommandAction="javascript:window.open('/Pages/Sample.aspx')" />



          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>

    </Elements>

    This may help you to resolve your problem.

                                                                      
    • Marked as answer by BlrSPDev Wednesday, October 31, 2012 7:21 AM
    Wednesday, October 31, 2012 7:19 AM
  • Thanks for your post. It is helping me. You saved my day.
    • Marked as answer by BlrSPDev Wednesday, October 31, 2012 5:41 PM
    Wednesday, October 31, 2012 7:21 AM

All replies

  • Hi namsdn,

     I have come crossed the same problem. Please try to follow the below steps.

     Steps

    Step1 --> Create a empty project and under this create a module and new empty element.

    Step2 --> Copy the below sample code in the element.xml file

    <?xml version="1.0" encoding="utf-8"?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <CustomAction
         Id="Ribbon.Sample"
         Location="CommandUI.Ribbon"
        >
        <CommandUIExtension>
          <CommandUIDefinitions>
            <CommandUIDefinition
              Location="Ribbon.Tabs._children">
              <Tab
                Id="Ribbon.CustomTbSample"
                Title="Sample button"
                Description=""
                Sequence="501">
                <Scaling
                  Id="Ribbon.CustomTbSample.Scaling">
                  <MaxSize
                    Id="Ribbon.CustomTbSample.MaxSize"
                    GroupId="Ribbon.CustomTbSample.CustomGroupExample"
                    Size="OneLargeTwoMedium" Sequence="1"/>
                  <Scale
                    Id="Ribbon.CustomTbSample.Scaling.CustomTabScaling"
                    GroupId="Ribbon.CustomTbSample.CustomGroupExample"
                    Size="OneLargeTwoMedium" Sequence="2"/>
                </Scaling>
                <Groups Id="Ribbon.CustomTbSample.Groups">
                  <Group
                    Id="Ribbon.CustomTbSample.CustomGroupExample"
                    Description="CMS Group"

                    Sequence="56"
                    Template="Ribbon.Templates.CustomTemplateExample">
                    <Controls Id="Ribbon.CustomTbSample.CustomGroupExample.Controls">
                      <Button
                        Id="Ribbon.CustomTbSample.CustomGroupExample.CMS"
                        Command="CustomTabExample.CMS"
                        Sequence="15"
                        Description="Manage Sample"
                        LabelText="Manage Sample"
                        TemplateAlias="btnCMS"
                        Image16by16="/Style Library/images/Ribbon/Sample.png"
                        Image32by32="/Style Library/images/Ribbon/Sample.png"

                        />



                    </Controls>
                  </Group>
                </Groups>
              </Tab>
            </CommandUIDefinition>
            <CommandUIDefinition Location="Ribbon.Templates._children">
              <GroupTemplate Id="Ribbon.Templates.CustomTemplateExample">
                <Layout
                  Title="OneLargeTwoMedium"
                  LayoutTitle="OneLargeTwoMedium">
                  <Section Alignment="Top" Type="OneRow">
                    <Row>
                      <ControlRef DisplayMode="Large" TemplateAlias="btnCMS" />
                    </Row>
                  </Section>



                </Layout>
              </GroupTemplate>
            </CommandUIDefinition>
          </CommandUIDefinitions>
          <CommandUIHandlers>
            <CommandUIHandler
              Command="CustomTabExample.CMS"
              CommandAction="javascript:window.open('/Pages/Sample.aspx')" />



          </CommandUIHandlers>
        </CommandUIExtension>
      </CustomAction>

    </Elements>

    This may help you to resolve your problem.

                                                                      
    • Marked as answer by BlrSPDev Wednesday, October 31, 2012 7:21 AM
    Wednesday, October 31, 2012 7:19 AM
  • Thanks for your post. It is helping me. You saved my day.
    • Marked as answer by BlrSPDev Wednesday, October 31, 2012 5:41 PM
    Wednesday, October 31, 2012 7:21 AM