Adding items into WikiPageTab

Jan 12, 2012 at 11:34 AM

I really belived, that my problems with adding new item into WikiPageTab or PublishTab was caused by Scale element in CommandUIDefinition. Unfortunately not completely. Maybe partly. When i use your XML, generated by FluentRibbon, and put him without any change into empty element (element.xml), it works. But when i want to create and run from feature, through ribbonCustomAction.Provision(ReceiverGuid, web), it doesn't work.

I don't know why. What's different in these two ways?

My code is same as your example for RibbonCustomAction.

Any ideas? Any help?

Thank you.

Reagrds,
Petr

Coordinator
Jan 12, 2012 at 1:34 PM

Petr, thanks for your feedback! I was able to reproduce the issue and now I'm working on fixing it.

Coordinator
Jan 12, 2012 at 2:06 PM
Edited Jan 13, 2012 at 6:38 AM

I've located the reason for such behavour. The problem is with RegistrationType and RegistrationId attributes:

RegistrationType           : ContentType
RegistrationId             : 0x

These are default values which Fluent Ribbon API uses.

And while this works great for binding the customization to all lists on site, this doesn't seem to affect pages.

I will consider possibilities for fixing this, without breaking the existing functionality. Probably, I'll have to create additional overload for Provision method or something like this.

As a temporary workaround, you can use the following code:

    var ribbonCustomActionForPages = new RibbonCustomAction();

    // We need to assign TemplateAlias manually to buttons, if they will be deployed separately
    var button1 = ControlLibrary.CreateRandomButton();
    button1.TemplateAlias = "o1";
    ribbonCustomActionForPages.AddControl(button1, SPRibbonIds.WikiPageTab.Groups.Manage.Id, 1);

    var customActionId = ribbonCustomActionForPages.Provision(ReceiverGuid, web);

    var customAction = web.UserCustomActions[customActionId];
    customAction.RegistrationType = SPUserCustomActionRegistrationType.None;
    customAction.RegistrationId = null;
    customAction.Update();
    web.Update();

So, the idea is to update custom action after its initial creation. I've tested this and was able to add a random button to Page tab of a wiki page.

Jan 12, 2012 at 2:20 PM

Awesome. Cool. Nice. It works with this hack/workaround ;-)

Jan 13, 2012 at 6:14 AM

Hi omlin,

what about the Scale attribute, please try to add anywhere new button or group to Ribbon with both scaling atribute, using CustomAction in element.xml. For me it doesn't work. When is in XML element Scale, i can't add this item into Ribbon. I don't know who is Chris O'Brian, but from my point of view, he has absolutely right. With this element inside it doesn't work. Perhaps it relates to element.xml only. I don't know :-(

Regards and thanks again for your fix,

Petr

Coordinator
Jan 13, 2012 at 6:31 AM
Edited Jan 13, 2012 at 6:31 AM

Petr, Fluent Ribbon works fine with Scale elements generated for each Group. And before bringing this into Fluent Ribbon, I've definetely tested all the code to work properly through the CAML (elements.xml).

Moreover, SharePoint itself uses Scale element extensively, you can ascertain it yourself, just open file

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\GLOBAL\XML\CMDUI.XML 

, and search for word "Scale". You will get tons of matches.

The tricky point here is that first child element in Scaling element must be MaxSize. It is mentioned on MSDN. Maybe that is your issue.

Jan 13, 2012 at 7:54 AM

OK, omlin, it could be. Really doesn't matter, important that your workaround works. That was only my note, i have noticed.

Please could you be so kind and when you will add new overload method for Provision method, could you add a new overload with SPSite. And for the and for RemoveAllCustomization method too, please. The SPWeb only for us isn't enough. We need to work with button through all sites and their webs. Currently we are able to add buttons through:

ribbonCustomAction.Provision(ReceiverGuid, site.UserCustomActions, ""ListForms.All, SPBasePermissions.EditListItems);

RemoveAllCustomization works only with SPWeb attibute, so we're working with Guid from Provision method to delete all custom actions.

if (ribbonButtonsCustomActionId != Guid.Empty)
			{
				SPUserCustomAction customAction = site.UserCustomActions[ribbonButtonsCustomActionId];
				customAction.Delete();
				customAction.Update();
			}

Thank you.
Best regards,
Petr

 

Coordinator
Jan 13, 2012 at 8:41 AM
Edited Jan 13, 2012 at 8:41 AM

Petr, that's really valuable suggestion, thanks! I can't realize how I've missed that :)

Will create corresponding issue and implement the proposed functionality as soon as possible.

Coordinator
Jan 21, 2012 at 6:21 AM

Petr, the proposed functionality was implemented in the "ab6f1e463098" changeset (Jan 21, 2012):

  1. I added value None to the ListTypes enumeration. Providing this value will allow to create page customizations. A bit awkward, I admit, and probably it will be changed in further releases.
  2. I added SPSite overloads for Provision and RemoveAllCustomizations methods.

The latest version of binaries can be downloaded from the Release 1.4 page.

Jan 23, 2012 at 6:38 AM
Edited Jan 23, 2012 at 6:39 AM

Hi omlin,

thanks a lot. We will test it and i'll give you a feedback.

Best regards, Petr

Jan 26, 2012 at 8:37 AM

Hi omlin,

it looks like everything works cool. I have noticed no problems during all tests.

Thanks a lot. Good work.

Best regards, Petr

Coordinator
Jan 26, 2012 at 9:09 AM

Petr, huge thanks for you feedback!

Please, feel free to ask any further questions or request improvements. Real-world usage experience is very important for the project and it definitely encourages me to continue the development.