How to get a Page widget from itemcollectioneditor.js

Member since: 2010

I am back to square one - I've managed to create a new tinymce button that adds a link to an anchor on a page.

Now, I have a new challange - I have to do the same for the linkitemcollection.

I have managed to render the dropdown in a link item using:

[EditorDescriptorRegistration(TargetType = typeof(LinkItemCollection), UIHint = SiteUiHints.ExtendedLinkCollection)]
    public class ExtendedLinkCollectionEditorDescriptor : ItemCollectionEditorDescriptor
    {
        public ExtendedLinkCollectionEditorDescriptor(
            IEnumerable<IContentRepositoryDescriptor> contentRepositoryDescriptors)
        {
            AllowedTypesFormatSuffix = "link"; 
            AllowedTypes = (from d in contentRepositoryDescriptors
                            where d.LinkableTypes != null && d.LinkableTypes.Any() 
                            select d).SelectMany(d => d.LinkableTypes).Distinct().ToArray();
        }
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            ClientEditingClass = "myproject/editors/ExtendedItemCollectionEditor";

            base.ModifyMetadata(metadata, attributes);
            var anonymousType = new
            {
                ItemModelType = "epi-cms/contentediting/viewmodel/LinkItemModel", 
                CustomTypeIdentifier = typeof(LinkItem).FullName.ToLower()
            }; 
            
            var value = new
            {
                DialogContentParams = new
                {
                    ModelType = typeof(ExtendedEPiLinkModel).FullName.ToLower()
                }
            };

            metadata.OverlayConfiguration["modelParams"] = anonymousType;
            metadata.EditorConfiguration["itemModelType"] = anonymousType.ItemModelType;
            metadata.EditorConfiguration["customTypeIdentifier"] = anonymousType.CustomTypeIdentifier; 
            metadata.EditorConfiguration["commandOptions"] = value;
        }

I "just" need to get hold of the Page widget, so that I can connect on its onChange event. The rest I can easily reuse. Can I do that from ExtendedItemCollectionEditor (at the moment, a copy paste of ItemCollectionEditor)?

Every help appreciated.

#86086 May 13, 2014 17:21
  • Member since: 2006

    Hi!

    My guess is to implement your own factory method to append the data there

      public class LinkItemSelectionFactory : ISelectionFactory

            {

                public IEnumerable<ISelectItem> GetSelections(ExtendedMetadata metadata)

                {

                    //add the onchange event to the items here

                    }

                    return list;

                }

            }

    and then in your Custom EditorDescription add

    SelectionFactoryType = typeof(LinkItemSelectionFactory);

    This stuff is very trial and error, best bet is to set an breakpoint and see what you got to deal with inside the factory.

    /Daniel

    #86382 May 20, 2014 15:57
  • Member since: 2010

    Hi, Daniel, thx for your answer, however, this is not what I need, since it statically filles out the dropdown. I need to re-populate my dropdown when Page is selected. So, I need to change dojo code to hook to the page input widget onChanged event.

    #86428 May 21, 2014 12:40
  • Member since: 2010

    After some time, I've realized I needed to take a different approach. If anyone else is wondering, I've written a blog post about it here.

    #86748 May 29, 2014 14:35