Toolbar Commands

Toolbar Commands

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Collections.ChildList
  • Sitecore.Context
  • Sitecore.Data.Database
  • Sitecore.Data.Items.Item

C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

const string htmlEditorProfile = "/sitecore/system/Settings/Html Editor Profiles/Rich Text Medium/Toolbar 1";
Sitecore.Data.Database db = Sitecore.Configuration.Factory.GetDatabase("core");
if (db == null) return;

Sitecore.Data.Items.Item toolbar = db.GetItem(htmlEditorProfile);
if (toolbar == null) return;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
output.Write("{0}", "Rich Text Medium Toolbar 1 Commands");
output.RenderEndTag(); //P          

Sitecore.Collections.ChildList toolbarCommands = toolbar.GetChildren();
foreach (Sitecore.Data.Items.Item command in toolbarCommands)
{
    output.Write("{0}&#58;&#160;{1}", "Toolbar command", "<b>" + command.Name + "</b><br/>");
}
      
output.RenderEndTag(); //Div

C# Web Control Real-time Output

Rich Text Medium Toolbar 1 Commands

Toolbar command: Print
Toolbar command: Find
Toolbar command: Divider
Toolbar command: Cut
Toolbar command: Copy
Toolbar command: Paste
Toolbar command: Paste Word
Toolbar command: Paste Word No Font Sizes
Toolbar command: Paste Plain Text
Toolbar command: Paste Html
Toolbar command: Clean
Toolbar command: Divider
Toolbar command: Undo
Toolbar command: Redo
Toolbar command: Divider
Toolbar command: Insert Sitecore Link
Toolbar command: Insert Sitecore Media
Toolbar command: Insert Link
Toolbar command: Unlink
Toolbar command: Insert Table
Toolbar command: Divider
Toolbar command: Insert Symbol
Toolbar command: Insert Snippet