Try our conversational search powered by Generative AI!

K Khan
Dec 28, 2023
(2 votes)

Top tip - Auto Suggestion for editors

Auto-suggestion can significantly enhance the efficiency, consistency, and overall quality of content created and managed by editors in a content management system. It serves as a valuable tool that supports editors in maintaining high standards and streamlining their workflow. This small feature can benefit editors in many ways such as saving time by predicting and suggesting words or phrases for some fields as they type. It can promote consistency in writing style and terminology across the content. Editors will adhere to specific style guides or content standards if required for some fields.

Developers can add simple built-in auto-suggestions for editors to select when working in the edit view of Optimizely Content Management System (CMS)

Create a Custom selection class by inheriting ISelectionQuery e.g.

using System;
    using System.Collections.Generic;
    using System.Linq;
    using EPiServer.ServiceLocation;
    using EPiServer.Shell.ObjectEditing;
      namespace EPiServer.Samples
        public class MySelectionQuery : ISelectionQuery
            SelectItem[] _items;
            public MySelectionQuery()
                _items = new SelectItem[] { 
                    new SelectItem() { Text = String.Empty, Value = String.Empty },
                    new SelectItem() { Text = "Alternative1", Value = "1" },
                    new SelectItem() { Text = "Alternative 2", Value = "2" } };
           //Will be called when the editor types something in the selection editor.
            public IEnumerable<ISelectItem> GetItems(string query)
                return _items.Where(i => i.Text.StartsWith(query, StringComparison.OrdinalIgnoreCase));
           //Will be called when initializing an editor with an existing value to get the corresponding text representation.
            public ISelectItem GetItemByValue(string value)
                return _items.FirstOrDefault(i => i.Value.Equals(value));

Add the AutoSuggestionEditor attribute with your properties as below and set the AllowCustomValues property to true so that the editor is not forced to select one of the suggested choices. By default, this property is set to false and the editor must select one of the suggested values.

public virtual string SelectionEditor1 { get; set; }
[AutoSuggestSelection(typeof(MySelectionQuery), AllowCustomValues = true)]
public virtual string SelectionEditor2 { get; set; }
Dec 28, 2023


Eric Petersson
Eric Petersson Jan 11, 2024 01:37 PM

Very nice and simple!

Please login to comment.
Latest blogs
Optimizely Web... 6 Game Changing Features in 2024

If you are interested in learning about what's new within Optimizely Web, you are in the right place. Carry on reading to learn about the 6 greates...

Jon Jones | Mar 3, 2024 | Syndicated blog

Headless forms reloaded (beta)

Forms is used on the vast majority of CMS installations. But using Forms in a headless setup is a bit of pain since the rendering pipeline is based...

MartinOttosen | Mar 1, 2024

Uploading blobs to Optimizely DXP via PowerShell

We had a client moving from an On-Prem v11 Optimizely instance to DXP v12 and we had a lot of blobs (over 40 GB) needing uploading to DXP as a part...

Nick Hamlin | Mar 1, 2024 | Syndicated blog

DbLocalizationProvider v8.0 Released

I’m pleased to announce that Localization Provider v8.0 is finally out.

valdis | Feb 28, 2024 | Syndicated blog