1

I'd like to add some custom actions for the pages on our site. These pages all have use the Page or Welcome Page Content Type.

Thanks.

2 Answers 2

3

To assign ribbon to all pages with specified content type, you can use RegistrationType="ContentType" and set RegistrationId to the content type Id.

For example:

<CustomAction 
   Id="AddRibbonForContentType" 
   Location="CommandUI.Ribbon"
   RegistrationType="ContentType" 
   RegistrationId="0x01080100E7218A6B458E40A49EF635CD​4E1228FF">
     <!-- Your ribbon definition here -->
</CustomAction>

Caution: Your content type id must be uppercase!

Read about CustomAction Element on MSDN for details.

Also it may be useful for you to read about Base Content Type Hierarchy. For example, according to that document, you can use "0x01010901" value to associate your ribbon customizations with all the web part pages.

5
  • Thanks. I'll take a look at your resources to see which Content Type I need to use. Looking back on it, I should have worded this better. I was on the right track with the RegistrationType but must have not been getting the right ID. Commented May 11, 2011 at 1:39
  • I am using the same approach but bot being able to add the Custom Actions to one of the Pages in the page library? I have made sure that RegistrationId is ID of Page Content Type and Type is ContentType. All the cases are upper also. Commented May 10, 2012 at 14:53
  • @FalakMahmood, the only thing I can think of is to try clearing browser cache, because browser occasionally caches the ribbon. Commented May 10, 2012 at 17:07
  • @AndreyMarkeev Every time I reload the page, I delete the page cache using the IE Developer tools. I can see the other changes (that I do to the Ribbon) though. Here is the code that I am using to replace Upload Button: pastebin.com/ZvZTjnkY Commented May 10, 2012 at 17:24
  • @FalakMahmood, not the cache then. Are you sure the Content Type ID (CTID) is correct? It's unexpectedly enormously long... Consider trying some other CTIDs, maybe some standard CTIDs from Base ContentType Hierarchy (the link is in the answer above). If it will work, then the problem is with CTID. Commented May 10, 2012 at 17:53
0

You can also check my blog post An in depth look at the ribbon control to get more information on how to customize the ribbon and add Silverlight or regular controls to it.

1
  • Great blog post @JohnnyT Commented May 11, 2011 at 1:52

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.