(Another) Question about extending LinkItemCollection with a new property/attribute


So far, I've seen quite a few people asking about this, and nobody following through with a sufficient solution, so I thought I would post with what I have so far, and see if anyone has any suggestions on what we're caught up on.

We're basing this on Jake Jones' approach, which I am not allowed to link to via this forum yet, but the idea is similar enough to adding a telephone link to this form.

We would like to add a new field to the LinkItem UI when adding a new link to the LinkItemCollection. We've successfully gone through the Dojo magic to have the dropdown appear and it saves values accordingly, so I think the hard part is completed. Keep in mind, the example below talks about a background color selector that we were just using as an example, but that's not the overall goal, so try not to focus on that part. The idea is we want to create a field to allow the user to select the type of icon (class) that will be assocaited with a button/link, and we will render the choice appropriately on the view.

Some code for an example:

 [EditorDescriptorRegistration(TargetType = typeof(LinkItemCollection), UIHint = "ExtendedLinkOptions")]
    public class LinkCollectionEditorDescriptor : ItemCollectionEditorDescriptor

   public override void ModifyMetadata(ExtendedMetadata metadata, System.Collections.Generic.IEnumerable<System.Attribute> attributes)
            base.ModifyMetadata(metadata, attributes);
            var f__AnonymousType = new
                ItemModelType = "epi-cms/contentediting/viewmodel/LinkItemModel",
                CustomTypeIdentifier = typeof(LinkItem).FullName.ToLower()
            var value = new
                DialogContentParams = new
                    ModelType = typeof(ExtendedLinkModel).FullName.ToLower()
            metadata.OverlayConfiguration["modelParams"] = f__AnonymousType;
            metadata.EditorConfiguration["itemModelType"] = f__AnonymousType.ItemModelType;
            metadata.EditorConfiguration["customTypeIdentifier"] = f__AnonymousType.CustomTypeIdentifier;
            metadata.EditorConfiguration["commandOptions"] = value;
    public class ExtendedLinkModel : LinkModel
        [DisplayName("Test Attribute")]
        [SelectOne(SelectionFactoryType = typeof(Collections.ModuleBackgroundColorSelectionFactory))]
        public string TestNewAttribute

Like I mentioned above, all of this is currently working. The problem is trying to retrieve the value of what the user selected on the backend for our views to render appropriately from our new ExtendedLinkModel class.

          Name = "Primary/Secondary CTA Buttons",
          Description = "Up to two links that will be used as primary and secondary buttons",
          GroupName = SystemTabNames.Content,
          Order = 90)]
        public virtual LinkItemCollection CTAs { get; set; }

We're still using LinkItemCollection in our models and this is not granting us access to this new attribute that the user is saving. We tried  extending LinkItemCollection and adding the property, but we're not sure how to exactly hook it up. When we try to add it in our models, episerver is unsure what the type is we're using. We started going down the rabbit hole of creating a new data type, but we can't find any documentation on that as well.

So ultimately, our questions are:

1) How do we retrieve the values associated with the new dropdown we created.

2) Do we have to have an ExtendedLinkItemCollection class as part of our models, and if so, what part are we missing so that Episerver is happy?

Please let me know if I can help clarify anything :) Thanks!

Jul 14, 2020 17:43
* 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.