Try our conversational search powered by Generative AI!

K Khan
Dec 28, 2023
  431
(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
    {
        [ServiceConfiguration(typeof(ISelectionQuery))]
        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.

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

Comments

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

Very nice and simple!

Please login to comment.
Latest blogs
Run imgproxy container on Azure App Service with Front Door CDN

A simple way to host a imgproxy Docker container and use it to get AVIF and WEBP images.

Johan Kronberg | May 5, 2024 | Syndicated blog

Why C# Developers Should Embrace Node.js

Explore why C# developers should embrace Node.js especially with Optimizely's SaaS CMS on the horizon. Understand the shift towards agile web...

Andy Blyth | May 2, 2024 | Syndicated blog

Is Optimizely CMS PaaS the Preferred Choice?

As always, it depends. With it's comprehensive and proven support for complex business needs across various deployment scenarios, it fits very well...

Andy Blyth | May 2, 2024 | Syndicated blog

Adding market segment for Customized Commerce 14

Since v.14 of commerce, the old solution  for adding market segment to the url is not working anymore due to techinal changes of .NET Core. There i...

Oskar Zetterberg | May 2, 2024

Blazor components in Optimizely CMS admin/edit interface

Lab: Integrating Blazor Components into Various Aspects of Optimizely CMS admin/edit interface

Ove Lartelius | May 2, 2024 | Syndicated blog

Anonymous Tracking Across Devices with Optimizely ODP

An article by Lead Integration Developer, Daniel Copping In this article, I’ll describe how you can use the Optimizely Data Platform (ODP) to...

Daniel Copping | Apr 30, 2024 | Syndicated blog