Any way to hide/remove the built in rich text widget?
I dont want the built in XbyK rich text widget appearing in the widget list, How can I hide it?
Environment
Xperience by Kentico version: [30.3.1]
.NET version: []
Execution environment: [local]
Link to relevant Xperience by Kentico documentation
Answers
We do this on all our projects, create a helper:
public static class WidgetRestrictionHelper
{
private static readonly string[] ExcludedWidgets =
{
SystemComponentIdentifiers.RICH_TEXT_WIDGET_IDENTIFIER,
SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER,
};
public static IEnumerable<string> GetAllWidgetsIdentifiers()
{
return new ComponentDefinitionProvider<Kentico.PageBuilder.Web.Mvc.WidgetDefinition>()
.GetAll()
.Select(definition => definition.Identifier)
.Where(identifier => !ExcludedWidgets.Contains(identifier));
}
}
Then in your views:
<editable-area area-identifier="widgets" area-options-allowed-widgets="@WidgetRestrictionHelper.GetAllWidgetsIdentifiers()" />
Thanks Liam! Thats an option. Any way to just do it by overriding built in settings so I can avoid updating my sections?
Not that I know of unfortunately, I think this is something we should be flagging in the roadmap as a suggestion. I'm pretty sure I've already submitted it, but I will submit it again now, and I recommend you do too!
It might be a small enough improvement they can slip it into an upcoming refresh? 🤞
There's a full Community Portal blog post on this topic - Defining Editable Area Restrictions.
But, Liam is correct. Widgets, Sections, and Page Templates are opt-out - even your own - through filters or restrictions. That's because they are globally registered with the [assembly: ]
attributes.
Not surprisingly there's an example of limiting which widgets are available in a Page Template in the Kentico Community Portal, which restricts the built-in Rich Text Widget from being available for blog posts.
To answer this question, you have to login first.