2

Here is the xml from element file. It's scope to web.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="HelloWorld"
                Title="Hello World"
                Location="CommandUI.Ribbon"
                RegistrationType="List"
                RegistrationId="101">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Manage.Controls._children">
          <Button Id="Ribbon.HelloWorld"
                  TemplateAlias="o1"
                  Command="HelloWorld"
                  LabelText="Hello world"/>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="HelloWorld"
                          CommandAction="javascript:alert('Hello world from ribbon !');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
  • to be clear, and I'm no great ribbon expert, are you trying see the ribbon in the context of the default custom list, i.e. you have the all items form for a generic custom list open when you look for your button? Because it looks like you're registering the button for that type of list and not as a global button. – GavinB Dec 6 '11 at 22:01
1

The following is the corrected code and is working now. Make sure to copy the image "copy_item.png" (http://www.iconfinder.com/icondetails/11062/32/copy_document_icon) to images folder (under 14 hive).

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
   Id="CustomRibbon"
   Location="CommandUI.Ribbon"
   RegistrationId="101"
   RegistrationType="List"
   Title="Copy Item to Doc Lib">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.Documents.Manage.Controls._children">
          <Button
           Id="Ribbon.Items.Manage.CustomRibbon"           
           Command="CopyItem"
           Image32by32="/_layouts/images/copy_item.png"
           LabelText="Copy Item"
           TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="CopyItem" CommandAction="javascript:alert('Hello world!');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
  • So... the only problem was that you weren't seeing an image? – Paul Lucas Dec 7 '11 at 22:44
0

The code provided works fine on my machine.

  1. Double check that the feature is activated on the web
  2. The button (as currently defined) will show up only on the list view page of a standard document library

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.