AI OnAI Off
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.
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
Hi All,
I need to make a couple of small changes to the Link title field on the 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