Update Link title field on LinkItemCollection

Vote:
 

Hi All,

I need to make a couple of small changes to the Link title field on the LinkItemCollection popup. 

LinkItemCollection popup

Specifically I need to change the label, and make the field required. Does anyone know how to do that?

I tried using the Editor Descriptors, outlined by Ander Hattestad https://world.optimizely.com/blogs/Anders-Hattestad/Dates/2015/2/extending-the-hyperlink-with-custom-field/,    Which let me modify the items in the radio button list. but not the title field.

I was also able to use Geta's new GenericLink to add a new field where I want it, which is super cool and something I am keeping in mind for the future, but it requires switching to a new property type, which is not a viable option due to all of the existing content.

In theory, I should be able to use dojo to update the control, but I haven't been able to find it in the modules zip files yet.

Any help or advice is greatly appreciated.

Joe Mayberry

#286066
Edited, Aug 24, 2022 13:40
Vote:
 

Hello Joe,

The easiest way to ensure Link title is populated is to use the IValidate<ContentType> class.  You could probably expand on the error message to elaborate on which entry it is.

public class MyPageValidator : IValidate<MyPage>
{
    public IEnumerable<ValidationError> Validate(MyPage instance)
    {
        if (!instance.MyLinkCollection.IsNullOrEmpty())
        {
            foreach (var linkItem in instance.MyLinkCollection)
            {
                if (string.IsNullOrWhiteSpace(linkItem?.Title))
                {
                    yield return new ValidationError
                    {
                        ErrorMessage = "My Link Collection contains an entry without a 'Link title'",
                        Severity = ValidationErrorSeverity.Error,
                        PropertyName = nameof(MyPage.MyLinkCollection)
                    };
                }
            }
        }
    }
}

If you wanted to use Geta's new GenericLink package (which we have and it's great) then you still could do so, but use Optimizely CMS MigrationSteps to transform the properties without dataloss in a one time migration, or add an extension method that gets your new property but falls back to Link title.

#286170
Aug 26, 2022 7:56
Vote:
 

Hi Mark,

Thank you for the response and great suggestion for a work around.

After a lengthy conversation wieghing the pros & cons, we have decided to move ahead and use Geta's GenericLink.

Thanks again,

Joe Mayberry

#286177
Aug 26, 2022 12:08
Mark Stott - Aug 26, 2022 12:11
Cool, I hope it works out well :)
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.