I’m building a custom data type using the user control wrappper method. Within it I am adding the existing TinyMCE data type. The problem is that I need to find a way to dynamically get a hold of the current TabPage on which the data type resides so that I can add the TinyMCE buttons to the menu. This is what I have currently (the TabPage is hardcoded):
Using statements:
using umbraco.cms.businesslogic.datatype;
using umbraco.editorControls.tinyMCE3;
using umbraco.uicontrols;
OnInit method:
private TinyMCE _tinymce = null;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.ID = "crte";
DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-87);
_tinymce = d.DataType.DataEditor as TinyMCE;
ConditionalRTEControls.Controls.Add(_tinymce);
TabView tabView = Page.FindControl("TabView1", true) as TabView;
TabPage tabPage = tabView.Controls[0] as TabPage;
tabPage.Menu.InsertSplitter();
tabPage.Menu.NewElement("div", "umbTinymceMenu_" + _tinymce.ClientID, "tinymceMenuBar", 0);
}
User control:
<asp:PlaceHolder ID="ConditionalRTEControls" runat="server" />
Note: Page.FindControl is using a custom extension method that recursively finds the control.
I’d love if there was a way to access the TabPage via the Umbraco API, but, after working on this for the past several hours, the only way I could get the tab was by traversing the parent controls until I came to the tab.
Code:
Extension Methods: