Custom Asset Pane Not Working

Vote:
 

I've been following https://cdisol.blog/2019/11/22/episerver-creation-and-management-of-non-common-content-types/comment-page-1/#comment-367 and have everything working as expected but I can't for the life of me get any other options on the root folder in the asset pane apart from create folder to appear so I can't create my FAQ content type. I have also tried making the top folder an actual folder type of my own and this showed the new item menu item but throwed issues in chrome xhr viewer when trying to create.

Anyone got a working one of these

using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using EPiServer.Web;

namespace Client.Web.Client.Domain.Models.Containers
{
    /// <summary>
    /// An FAQ in the system
    /// </summary>
    [ContentType(DisplayName = "FAQ", GUID = "B3DFB166-792F-4EDC-AA57-E1333844BF4A", Description = "FAQ information for display on the website")]
    public class Faq : StandardContentBase
    {
        /// <summary>
        /// Gets or sets the question.
        /// </summary>
        /// <value>
        /// The question.
        /// </value>
        [Display(Name = "Question", Description = "The question", Order = 1)]
        [Required]
        [StringLength(75)]
        public virtual string Question { get; set; }

        /// <summary>
        /// Gets or sets the answer.
        /// </summary>
        /// <value>
        /// The answer.
        /// </value>
        [Display(Name = "Answer", Description = "The answer to the question", Order = 2)]
        [Required]
        [UIHint(UIHint.Textarea)]
        [StringLength(350)]
        public virtual string Answer { get; set; }

        /// <summary>
        /// Gets or sets the full answer.
        /// </summary>
        /// <value>
        /// The full answer.
        /// </value>
        [Display(Name = "Full Answer", Description = "The full answer for showing on the large list", Order = 3)]
        [Required]
        public virtual XhtmlString FullAnswer { get; set; }
    }
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.ServiceLocation;
using EPiServer.Shell;
using EPiServer.Web;
using Client.Web.Client.Domain.Models.Containers;

namespace Client.Web.Client.Assets
{
    /// <summary>
    /// Descriptor for the review pane
    /// </summary>
    /// <seealso cref="ContentRepositoryDescriptorBase" />
    [ServiceConfiguration(typeof(IContentRepositoryDescriptor))]
    public class FaqPaneDescriptor : ContentRepositoryDescriptorBase
    {
        private readonly ContentReference _root;

        public static string RepositoryKey => "FaqPaneDescriptor";

        public static string RootName => "FAQs";

        /// <summary>
        /// Initializes a new instance of the <see cref="FaqPaneDescriptor"/> class.
        /// </summary>
        public FaqPaneDescriptor()
        {
            var contentRootService = ServiceLocator.Current.GetInstance<ContentRootService>();
            _root = contentRootService.Get(RootName);
        }


        public override string Key => RepositoryKey;

        public override string Name => RootName;

        /// <summary>
        /// Gets the contained types.
        /// </summary>
        /// <value>
        /// The contained types.
        /// </value>
        public override IEnumerable<Type> ContainedTypes
        {
            get { return new[] { typeof(Faq), typeof(ContentFolder) }; }
        }

        /// <summary>
        /// Gets the creatable types.
        /// </summary>
        /// <value>
        /// The creatable types.
        /// </value>
        public override IEnumerable<Type> CreatableTypes
        {
            get { return new List<Type> { typeof(Faq), typeof(ContentFolder) }; }
        }

        public override IEnumerable<ContentReference> Roots
        {
            get { return new[] { _root };  }
        }

        public override IEnumerable<Type> LinkableTypes
        {
            get { return new List<Type> { typeof(Faq) }; }
        }


        /// <summary>
        /// Gets the main navigation types.
        /// </summary>
        /// <value>
        /// The main navigation types.
        /// </value>
        public override IEnumerable<Type> MainNavigationTypes
        {
            get { return new[] { typeof(ContentFolder) }; }
        }
    }
}
using EPiServer.Shell;
using EPiServer.Shell.ViewComposition;

namespace Client.Web.Client.Assets
{
    /// <summary>
    /// Component for FAQ section
    /// </summary>
    /// <seealso cref="ComponentDefinitionBase" />
    [Component]
    public class FaqPaneNavigationComponent_: ComponentDefinitionBase
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FaqPaneNavigationComponent_"/> class.
        /// </summary>
        public FaqPaneNavigationComponent_() : base("epi-cms/asset/HierarchicalList")
        {
            base.Title = "FAQs";
            Categories = new[] { "content" };
            PlugInAreas = new[] { PlugInArea.AssetsDefaultGroup, PlugInArea.NavigationDefaultGroup };
            SortOrder = 1000;
            base.Settings.Add(new Setting("repositoryKey", FaqPaneDescriptor.RepositoryKey));
            base.Settings.Add(new Setting("noDataMessages", new { single = "This folder does not contain any locations", multiple = "These folders do not contain any locations" }));
        }
    }
}
using System;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
using Client.Web.Client.Assets;
using Client.Web.Client.Domain.Models.Containers;

namespace Client.Web.Client
{
    /// <summary>
    /// The FAQs root folder
    /// </summary>
    /// <seealso cref="EPiServer.Framework.IInitializableModule" />
    [InitializableModule]
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class FaqsRootInitialization_: IInitializableModule
    {
        public void Initialize(InitializationEngine context)
        {
            var contentRootService = context.Locate.Advanced.GetInstance<ContentRootService>();

            // We create a folder at the root level called People 
            contentRootService.Register<ContentFolder>(FaqPaneDescriptor.RootName, new Guid("C6CFA6E9-6999-4F5B-A471-A994D528999C"), ContentReference.RootPage);
        }

        public void Uninitialize(InitializationEngine context)
        {

        }
    }
}
#218359
Edited, Mar 11, 2020 14:41
Vote:
 

Hi Scott,

I've created a fair few of these and have not had this issue but using your code above I was able to recreate the scenario. For comparison, I lifted over a very similar example I had and it worked.

I started to align the code to see if I could figure out what was going on, and I got yours workingalthough I'm not sure why. In your FaqPaneDescriptor if you update any getters which return a List<Type> to Type[] and you'll (hopefully) see that it works.

As I said, I'm not sure why (was thinking it could possibly be serialization related, although not convinced) but if you figure anything out I'd be interested.

#218491
Edited, Mar 13, 2020 16:37
* 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.