The name/text field comes from the LinkItem object where it is required.
An alternative to the LinkItemCollection is to create your own link list which can be done in a few different ways, the ideal solution would probably be using the Episerver.Url object. The Url object unfortunately lack a constructorless parameter so it is not usable in a IList property just yet, but it may be improved in 12.18.
That implementation would in that case look like this
[Display(
GroupName = SystemTabNames.Content,
Order = 30)]
public virtual IList<Url> UrlList { get; set; }
Since we dont have that just yet, are you planning to link only internal pages and resources you'll probably find using a ContentReference list the easiest to implement, e.g.
[Display(
GroupName = SystemTabNames.Content,
Order = 30)]
public virtual IList<ContentReference> ContentReferences { get; set; }
If you still want to use the Url property but create a custom propertylist something like this may suffice
[Display(
GroupName = SystemTabNames.Content,
Order = 30)]
[JsonProperty]
[JsonConverter(typeof(UrlConverter))]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<Link>))]
public virtual IList<Link> Urls { get; set; }
Where Link would be a property list looking something like this
public class Link
{
[Display(Name = "Title", Description = "", GroupName = SystemTabNames.Content, Order = 1)]
public virtual string NonRequiredTitle { get; set; }
[Display(Name = "Link", Description = "", GroupName = SystemTabNames.Content, Order = 2)]
public virtual Url LinkTo { get; set; }
}
[PropertyDefinitionTypePlugIn]
public class LinksProperty : PropertyList<Link> { }
I didn't really test the PropertyList<Link> solution with CMS 12 and it is heavily inspired by this solution https://world.optimizely.com/forum/developer-forum/CMS/Thread-Container/2019/6/url-property-disappear-when-adding-and-publishing/
Eric Herlitz Thank you for response.
I am agree with your alternate solution. But our requirement is to set any url that can be either internal or external. I am using LinkItemCollection becuase this property returns external url and internal page details both. But url property desn't return internal page detail. So I believe you alternate solution will not work for me
Here is LinkItemCollection property api response.
Hello Team,
I am using LinkItemCollection property into the page. When I am creating a new link, system is forcing me to add the Link name/text field value. Can we set the default value or make it this field optional ?
Thanks & Regards
Binay Thakur