Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Josip 152 posts 594 karma points c-trib
    14 days ago
    Josip
    0

    Add custom fields in MembersIndex

    Hi all,

    I have more than 1000 category nodes and more than 1000 members with MNTP where they can select this category nodes, now i need to create navigation menu where I will list all categories, but I need to hide categories which are not selected by any member.

    Now I need the fastest way to find out which category is not picked by any member. First thing that come to my mind is to include MNTP field in MemberIndex and searh it with examine.

    But I am not sure is it good idea or there are better ways to do that and I dont know where to start. If someone can give me some code examples how to extend MembersIndex I would appreciate that.

  • Josip 152 posts 594 karma points c-trib
    1 week ago
    Josip
    0

    Ok I found in documentation how to do that but I have few red underlines in IndexCreator class, which I dont how to get rid off them.

    enter image description here

    public class SupplierIndexCreator : UmbracoIndexesCreator
    {
        public SupplierIndexCreator(IProfilingLogger profilingLogger, ILocalizationService languageService, IPublicAccessService publicAccessService, IMemberService memberService, IUmbracoIndexConfig umbracoIndexConfig)
        : base(profilingLogger, languageService, publicAccessService, memberService, umbracoIndexConfig)
        {
        }
    
        // note - in Umbraco 8.4 this method is obsoleted and it's advised to replace the
        // IUmbracoIndexConfig as in the above example.
        public override IValueSetValidator GetMemberValueSetValidator()
        {
            // all built in member properties to exclude (i.e. Password question, etc...)
            var excludeFields = Constants.Conventions.Member.GetStandardPropertyTypeStubs().Keys;
    
            // include everything except the above
            return new MemberValueSetValidator(null, null, null, excludeFields);
        }
    }
    
  • Josip 152 posts 594 karma points c-trib
    1 week ago
    Josip
    0

    I solved problem with red underscores but now I need to change MNTP value because I cant search this umb://document/dcaf10aba21d43ad804f3f0749a06af4,umb://document/46041db839024511bcc4546b3866a4ab,umb://document/78289077c0434294a7e031ced3936b16,umb://document/2571ed7b648840168e3e880770a5a413

    So I want to replace comas with space and for that I need to create new event. I found this post : https://shazwazza.com/post/searching-multi-node-tree-picker-data-or-any-collection-with-examine/ But its out of date. Right now i have this:

     public class SuppliersMNTP : IComponent
    {
        private readonly IExamineManager examineManager;
        public SuppliersMNTP(IExamineManager examineManager)
        {
            this.examineManager = examineManager;
        }
    
        public void Initialize()
        {
            var membersIndex = examineManager.Indexes.FirstOrDefault(i =>
                      i.Name.Equals("MembersIndex"));
            if (membersIndex != null)
            {
                ((BaseIndexProvider)membersIndex).TransformingIndexValues += ExternalTransformingIndexValues;
            }
        }
    
        public void Terminate() { }
    
        private void ExternalTransformingIndexValues(object sender, IndexingItemEventArgs e)
        {
    
        }
    }
    

    But I dont know what I should put in ExternalTransformingIndexValues . I am stuck here. Please help :)

Please Sign in or register to post replies

Write your reply to:

Draft