[Umbraco] Add more than one TinyMCE datatype on page or usercontrol

        private void addTinyMCEControl(Control targetPlaceHolder, TabPage tp)
{

DataTypeDefinition htmlEditorDataType =
DataTypeDefinition.GetDataTypeDefinition(new Guid("A521511A-7BEE-4C5B-8D7B-4B06B57392B3"));

//The other way can get datatype id directly.
//DataTypeDefinition htmlEditorDataType = DataTypeDefinition.GetDataTypeDefinition(-87);

TinyMCE umbracoTinyMCEEditor = (TinyMCE)htmlEditorDataType.DataType.DataEditor;

string toolbar_id = string.Empty;

if (umbracoTinyMCEEditor != null)
{
if (umbracoTinyMCEEditor.config["umbraco_toolbar_id"] != null)
umbracoTinyMCEEditor.config.Remove("umbraco_toolbar_id");
toolbar_id = "tinyMCEMenu_" + targetPlaceHolder.ClientID;
umbracoTinyMCEEditor.config.Add("umbraco_toolbar_id", toolbar_id);
targetPlaceHolder.Controls.Add(umbracoTinyMCEEditor);
tp.Menu.NewElement("div", toolbar_id, "tinymceMenuBar", 0);
}
}


Reference:


沒有留言:

張貼留言