Copied to clipboard

Flag this post as spam?

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


  • Josip 111 posts 440 karma points
    Apr 16, 2019 @ 17:43
    Josip
    0

    Get Members where the property (MNTP) contains the name of the page

    I added Multinode Treepicker for the members. On a specific page I want to show the members who selected that page on the MNTP. (It can be filtered by page name, id guid, uid etc...)

         @{
        var pageName = Model.Name;
    
        var member = Services.MemberService.GetAllMembers();
    }
    
    
    @foreach (var item in member)
    {
        @item.Name
    }
    
  • Josip 111 posts 440 karma points
    Apr 17, 2019 @ 15:49
    Josip
    0

    I solved it like this, but i am not sure is this the good way to do that, any advice would be appreciated

    @{
        var pageName = Model.Name;
        var members = Services.MemberService.GetAllMembers();
        var memberCounter = 0;
    }
    <p>Page Name: @pageName</p>
    
    @foreach (var member in members)
    {
        var check = false;
        var typedMultiNodeTreePicker = member.GetValue<string>("categoryPicker");
        if (typedMultiNodeTreePicker != null)
        {
            foreach (var udi in typedMultiNodeTreePicker.Split(','))
            {
                var categories = Umbraco.Content(Udi.Parse(udi)).Yield()
                                                 .Where(x => x.IsVisible())
                                                 .ToArray();
    
                foreach (var category in categories)
                {
                    if (category.Name == pageName)
                    {
                        check = true;
                        memberCounter++;
                    }
                }
            }
        }
        if (check == true)
        {
            @member.Name <br />
            @member.GetValue("phoneNumber") <br />
            @member.Email
        }
        <hr />
    }
    <p>Number of Companies: @memberCounter</p>
    
Please Sign in or register to post replies

Write your reply to:

Draft