Copied to clipboard

Flag this post as spam?

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


  • Gabriel Palomino 2 posts 22 karma points
    Oct 12, 2013 @ 00:42
    Gabriel Palomino
    0

    List Members

    Trying to output a list of members to a page. I have the output coming out fine with typical fields(text, textarea, checkboxes and even dropdowns) But the problem is showing the output for a Ucomponent(MNTP).

    I have this component grabbing pages from a certain folder and just assigning the member to this page.

    The problem is I cannot get the component to show me the Page Name and Url.It comes out as XML and cannot figure out how to just get the nodeproperties out of it.

    Below is what I have:

    @using umbraco.cms.businesslogic.member
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.NodeFactory
    @{
    var members = Member.GetAll;
    <h2>All Members</h2>
    foreach(var item in members){
      var member = new Member(Convert.ToInt32(@item.Id));
    // OTHER VARS HERE....
    <p>Company Name: @(member.GetProperty<string>("companyName"))</p>
    }
    }

    Output shows:

    Var1: CorrectValue1
    Var2: CorrectValue2

    Company Name: <MultiNodePicker type="content"> <nodeId>1475</nodeId> </MultiNodePicker>

     

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Oct 12, 2013 @ 08:55
    Jeavon Leopold
    1

    Hi Gabriel,

    Welcome to Our!

    Because your MNTP is storing as XML (and could potentially have multiple selections) you need to a bit of processing, here is how I would do it:

    @using umbraco.cms.businesslogic.member
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco
    @using umbraco.MacroEngines
    @{
    var members = Member.GetAll;
    <h2>All Members</h2>
    foreach(Member item in members){ 
    // OTHER VARS HERE....
        if (item.HasProperty("companyName"))
        {
            int[] nodeList = uQuery.GetXmlIds(item.GetProperty<string>("companyName"));      
            IEnumerable<DynamicNode> publishedNodeList = Library.NodesById(nodeList.ToList());        
            publishedNodeList = publishedNodeList.Where(x => x.GetType() != typeof(DynamicNull) && x.Id > 0);                        
            dynamic multiNodeTreePicker = new DynamicNodeList(publishedNodeList);
    
            if (multiNodeTreePicker.Any())
            {             
                <p>Comapny Name: @multiNodeTreePicker.First().Name</p>                    
            }        
        }
      }
    }
    

    Thanks,

    Jeavon

  • Gabriel Palomino 2 posts 22 karma points
    Oct 12, 2013 @ 20:53
    Gabriel Palomino
    0

    Jeavon,

    That did it!

    I knew I had to gather the XML and then grab its varibales. i just did not know how to.

    Thanks again!

     

Please Sign in or register to post replies

Write your reply to:

Draft