RibbonDefinition as pure string/xml

Jan 8, 2012 at 1:36 PM
Edited Jan 8, 2012 at 1:43 PM

Hi again :)

So, in my project I use SPRibbon and it pretty cool!

The idea goes like this.

1) I want to remove SPRibbon dependency. Sounds not so good, but as it is. I just don't want to distribute SPRibbon dll with my project and having additional 3rd part dependency.

2) To make (1) true I built up some infrastructure for registering ribbon xml-definition and now I want to use SPRibbon library as service for building just pure xml strings which will be used in my project and will be storedin resources/constants.

3) Also, it could be used with T4 for ribbon-xml generation as resources/conts. In that case we have no 3rd part dependency, but it wouldn't suit all the projects. 

So, is there any way to get pure string/xml from RibbonDefinition class or another classes and use SPRibbon just as T4/console/winapp/webui-based ribbon-definition builder/wizard?

Jan 8, 2012 at 3:51 PM
Edited Jan 8, 2012 at 3:52 PM

The idea is really great, thank you. I will debate it and consider if such kind of functionality deserves to be included in the next product release.

For now, there is actually a workaround to use it. Please, consider the following scenario:

  1. Create your ribbon definition using Fluent Ribbon API
  2. Deploy it to your site, using RibbonCustomAction functionality and its Provision(Guid, SPWeb) method
  3. Go to PowerShell, grab the SPWeb object, and use UserCustomActions property to retrieve all custom actions of the site
  4. Finally, find your custom action (it must be the last one), and display its CommandUIExtension property (or you can save it to a file)

The powershell code will look something like this:

$web = Get-SPWeb http://localhost
$customAction = $web.UserCustomActions | select -Last 1
$customAction.CommandUIExtension > 1.txt
Jan 8, 2012 at 5:03 PM

Well, it would be too complicated for complex scenarios. Thanks for helping.