sitecore

Sitecore create drop-down button in RTE populated from master database


I'm trying to create a drop-down button for the rich text editor (RTE) in Sitecore but cannot figure out how to implement this. I would like something similar to the 'Insert Snippet' command shown below, but with the source of the dropdown driven by content from the master database instead of core items within the html editor profile. enter image description here

The closest approach I've found is this article which describes how to add a button which opens a dialog in the RTE.

Another option could be to have a save handler which can create the snippet items in the core database based when items are created/edited in a certain area of the master database.


Solution

  • Inherit Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration. If you just want to add snippets to the standard snippets list, just override the SetupSnippets method and add to the Editor.Snippets collection.

    If you want to add your own dropdown, it will get more complicated, but you can probably override the SetupToolbars method and add an EditorToolGroup with an EditorDropDown. You might want to look at Telerik's documentation for the RadEditor if you run into any problems.

    Once you have a draft of your class written, register it by going to the profile definition in the core database under /sitecore/system/Settings/Html Editor Profile. Each profile has a Configuration Type item where you can specify the type signature of your class.