Hi DW,
I'm playing around with ribbon extenders and items, and it seems that it isn't completely supported yet. But i did some hacking around anyway, and i found a few quirks, that i hope theres a workaround for.
Here are my findings:
- Dynamicweb.Controls.Extensibility.RibbonBarAddInTarget.General doesn't contain ItemAsPageEdit and ItemAsParagraphEdit (Or what ever the names should be). To get it working i had to add [AddInTarget("/Admin/Content/Items/Editing/ItemEdit.aspx")] to my class.
- base.Ribbon.DataContext.DataSource is null and this makes it harder to get access to the item you're editing
- PopUpWindows don't open above page. Opening a PopupWindow looks like this:
It seems the popup window is created in the wrong frame
This is my extension class that provoked the above mentioned issue
using System; using System.Collections.Generic; using System.Linq; using Dynamicweb.Content; using Dynamicweb.Controls; using Dynamicweb.Controls.Extensibility; using Dynamicweb.Extensibility; using Dynamicweb.Content.Items; namespace MyNamespace.Ribbon { [AddInTarget("/Admin/Content/Items/Editing/ItemEdit.aspx")] [AddInDescription("Tilføj Åbningstider")] [AddInName("OpeningHours")] public class ParagraphEditAddInOpeningHours : RibbonBarAddIn { /// <summary> /// Initializes a new instance of the ParagraphEditAddInOpeningHours class. /// </summary> public ParagraphEditAddInOpeningHours(RibbonBar ribbon) : base(ribbon) { } public override void Load() { // Create new group in ribbon RibbonBarGroup group = base.CreateDefaultContainer(); // Datasource is null - So no access to the element we're rendering Item item = base.Ribbon.DataContext.DataSource as Item; // Workaround because we have no datasource var querystring = base.Page.ClientQueryString; // contains something like "PageID=62" var itemID = querystring.Split('=')[1]; // Create popup window PopUpWindow window = new PopUpWindow(); window.ID = "OpeninghourWindow"; window.AutoReload = true; window.ShowHelpButton = false; window.ContentUrl = string.Concat("/CustomModules/OpeninghoursEditor/OpeninghoursEditor.aspx?ID=", itemID); base.AddWindow(window); // Add button to ribbon RibbonBarButton button = new RibbonBarButton(); button.Size = Dynamicweb.Controls.Icons.Icon.Size.Large; button.Text = "Åbningstider"; button.Image = Dynamicweb.Controls.Icons.Icon.Type.AddDocument; button.OnClientClick = Dynamicweb.Controls.PopUpWindow.GetClientMethodCall(window, Dynamicweb.Controls.PopUpWindowMethod.Show); group.AddItem(button); } } }
If i can fix any of the bullets above, please let me know :-)
Also, when do you think that you will support Ribbon extensions for Items?
// Martin.