3

I am trying to create a Dropdown in WYSIWYG. I have added the Item using the Html Editor Drop Down Button template and Dropdown values using the Html Editor List Item in the core database. However, it's not showing the values when I open the RTE. Is there any configuration file that I need to edit as well?

enter image description here

enter image description here

7
  • Can you provide screenshots to what you have set up so far? Commented Feb 1, 2020 at 17:55
  • @Asad: This blog post describes the detailed steps to configure a custom dropdown list button in the Rich Text Editor in Sitecore 9: sitecorerunner.com/2018/08/21/… Commented Feb 1, 2020 at 20:28
  • @AlessandroFaniuolo Thank you for sharing the link. Do we have to override the EditorConfiguration.cs even if we are using the Sitecore HTML Editor Profiles template to create Sitecore items? So my understanding was that it should work once you add the items as the child list items under the dropdown button.
    – Asad Syed
    Commented Feb 2, 2020 at 14:13
  • @MichaelWest , Please see the screenshots of the items that I added for the Dropdown.
    – Asad Syed
    Commented Feb 2, 2020 at 14:15
  • @Asad You don't need to override it, unless you want to organize the items to list in the dropdown field under a separate folder, instead of creating them as child items of your "Html Editor Drop Down Button" custom item. Commented Feb 2, 2020 at 14:45

1 Answer 1

4

This blog post describes the detailed steps to configure a custom dropdown list button in the Rich Text Editor in Sitecore 9: https://sitecorerunner.com/2018/08/21/adding-rte-richtext-custom-dropdown-list-in-sitecore-9/

One thing that is not explicitly called out in the article is that you need to use the Html Editor Custom Drop Down Button template when creating a custom dropdown button item, instead of the Html Editor Drop Down Button template, if you want that the dropdown button lists the child items defined using Html Editor List Item template.

Indeed in the Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration class, the SetupToolbar method invoked to configure each button has a conditional logic based on the template of the button items to initialize buttons in different ways. In particular, when the template name of the button item is Html Editor Custom Drop Down Button, the internal SetChildren method is called to initialize the list of items to populate the drowdown:

private static void SetChildren(EditorDropDownItemCollection items, Item parent)
{
      Assert.ArgumentNotNull((object) items, nameof (items));
      Assert.ArgumentNotNull((object) parent, nameof (parent));
      foreach (Item child in parent.Children)
      {
        if (child.TemplateName == "Html Editor List Item")
          ((EditorNameValueItemCollection<EditorDropDownItem>) items).Add(child["Header"], child["Value"]);
      }
}
1
  • Yes, Thank you very much. This makes sense and it worked perfectly.
    – Asad Syed
    Commented Feb 2, 2020 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.