1

I have the following code which creates for me a custom tab, custom group and a custom button called Skills, but how Can I create a new button called Education? in same group but with different CommandAction?

<?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <CustomAction
     Id="CustomRibbonTab"
     Location="CommandUI.Ribbon"
     RegistrationId="0x01040004DF150B6311CB4D8A33D0764922EDF6"  
     RegistrationType="ContentType">
     <CommandUIExtension>
       <CommandUIDefinitions>
         <CommandUIDefinition
           Location="Ribbon.Tabs._children">
           <Tab
            Id="Ribbon.CustomTab1"
            Title="Skills"
            Description="skills Tab !!!"
            Sequence="501">
             <Scaling
               Id="Ribbon.CustomTab1.Scaling">
               <MaxSize
                 Id="Ribbon.CustomTab1.MaxSize"
                 GroupId="Ribbon.CustomTab1.CustomGroup"
                 Size="OneLargeTwoMedium"/>
               <Scale
                 Id="Ribbon.CustomTab1.Scaling.CustomTabScaling"
                 GroupId="Ribbon.CustomTab1.CustomGroup"
                 Size="OneLargeTwoMedium" />
             </Scaling>
             <Groups Id="Ribbon.CustomTab1.Groups">
               <Group
                 Id="Ribbon.CustomTab1.CustomGroup"
                 Description="Custom Group!"
                 Title="Custom Group"
                 Sequence="52"
                 Template="Ribbon.Templates.CustomTemplate">
                 <Controls Id="Ribbon.CustomTab1.CustomGroup.Controls">
                   <Button
                     Id="Skillsbutton"
                     Command="CustomTab.CustomButtonCommand"
                     Sequence="15"
                     Description=""
                     LabelText="Skills"
                     Image32by32="/_layouts/images/PPEOPLE.GIF"
                     TemplateAlias="cust1"/>
                 </Controls>
               </Group>
             </Groups>
           </Tab>
         </CommandUIDefinition>
         <CommandUIDefinition Location="Ribbon.Templates._children">
           <GroupTemplate Id="Ribbon.Templates.CustomTemplate">
             <Layout
               Title="OneLargeTwoMedium"
               LayoutTitle="OneLargeTwoMedium">
               <Section Alignment="Top" Type="OneRow">
                 <Row>
                   <ControlRef DisplayMode="Large" TemplateAlias="cust1" />
                 </Row>
               </Section>
             </Layout>
           </GroupTemplate>
         </CommandUIDefinition>
       </CommandUIDefinitions>
       <CommandUIHandlers>
         <CommandUIHandler
           Command="CustomTab.CustomButtonCommand"
            CommandAction="javascript:SP.UI.ModalDialog.ShowPopupDialog('http://london/SitePages/empl.aspx');" />
       </CommandUIHandlers>
     </CommandUIExtension>
   </CustomAction>
 </Elements>

I tried to add a new button but everything messed up.

Thanks.

4

It's actually very simple! :)
You only have to duplicate the <Button tag and the <CommandUIHandler tag. Also be sure to duplicate the <ControlRef in the <Layout, or else the new button will not show. Something like:

<?xml version="1.0" encoding="utf-8"?>
 <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <CustomAction
     Id="CustomRibbonTab"
     Location="CommandUI.Ribbon"
     RegistrationId="0x01040004DF150B6311CB4D8A33D0764922EDF6"  
     RegistrationType="ContentType">
     <CommandUIExtension>
       <CommandUIDefinitions>
         <CommandUIDefinition
           Location="Ribbon.Tabs._children">
           <Tab
            Id="Ribbon.CustomTab1"
            Title="Skills"
            Description="skills Tab !!!"
            Sequence="501">
             <Scaling
               Id="Ribbon.CustomTab1.Scaling">
               <MaxSize
                 Id="Ribbon.CustomTab1.MaxSize"
                 GroupId="Ribbon.CustomTab1.CustomGroup"
                 Size="OneLargeTwoMedium"/>
               <Scale
                 Id="Ribbon.CustomTab1.Scaling.CustomTabScaling"
                 GroupId="Ribbon.CustomTab1.CustomGroup"
                 Size="OneLargeTwoMedium" />
             </Scaling>
             <Groups Id="Ribbon.CustomTab1.Groups">
               <Group
                 Id="Ribbon.CustomTab1.CustomGroup"
                 Description="Custom Group!"
                 Title="Custom Group"
                 Sequence="52"
                 Template="Ribbon.Templates.CustomTemplate">
                 <Controls Id="Ribbon.CustomTab1.CustomGroup.Controls">
                   <Button
                     Id="Skillsbutton"
                     Command="CustomTab.CustomButtonCommand"
                     Sequence="15"
                     Description=""
                     LabelText="Skills"
                     Image32by32="/_layouts/images/PPEOPLE.GIF"
                     TemplateAlias="cust1"/>
                   <Button
                     Id="Educationbutton"
                     Command="CustomTab.EducationButtonCommand"
                     Sequence="16"
                     Description=""
                     LabelText="Education"
                     Image32by32="/_layouts/images/Education.GIF"
                     TemplateAlias="cust2"/>
                 </Controls>
               </Group>
             </Groups>
           </Tab>
         </CommandUIDefinition>
         <CommandUIDefinition Location="Ribbon.Templates._children">
           <GroupTemplate Id="Ribbon.Templates.CustomTemplate">
             <Layout
               Title="OneLargeTwoMedium"
               LayoutTitle="OneLargeTwoMedium">
               <Section Alignment="Top" Type="OneRow">
                 <Row>
                   <ControlRef DisplayMode="Large" TemplateAlias="cust1" />
                   <ControlRef DisplayMode="Large" TemplateAlias="cust2" />
                 </Row>
               </Section>
             </Layout>
           </GroupTemplate>
         </CommandUIDefinition>
       </CommandUIDefinitions>
       <CommandUIHandlers>
         <CommandUIHandler
           Command="CustomTab.CustomButtonCommand"
            CommandAction="javascript:SP.UI.ModalDialog.ShowPopupDialog('http://london/SitePages/empl.aspx');" />
         <CommandUIHandler
           Command="CustomTab.EducationButtonCommand"
            CommandAction="__todo: your action here__" />
       </CommandUIHandlers>
     </CommandUIExtension>
   </CustomAction>
 </Elements>
  • now it is not displaying any button, both of skills and education button disappeared. Why? – Nderon Hyseni Sep 2 '16 at 9:34
  • Did you use the exact code above? Did you replace the todo CommandAction? It's most probably a syntax error somewhere in the XML. The concept is correct (I use it all the time). – Evariste Sep 2 '16 at 9:48
  • yes I replaced CommandAction with my own javascript – Nderon Hyseni Sep 2 '16 at 9:49
  • 1
    The Layout has only one ControlRef. Don't you need two to make the button show? With different `TemplateAlias' ? – Nils Sep 2 '16 at 11:26
  • 1
    You'll need to add a new Group with a new Id. Then you'll need to duplicate MaxSize and Scale and modify their GroupId accordingly. I think you can re-use the Template - no need to copy it. – Nils Sep 2 '16 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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