Copied to clipboard

Flag this post as spam?

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


  • Tony Kiernan 278 posts 341 karma points
    Feb 24, 2011 @ 13:42
    Tony Kiernan
    0

    Getting members xml with eiter GetMember or GetXmlAll

    Wanting to output all members to a Google map. I've done this using a usercontrol querying the database directly. It can be a bit sluggish. Is there any way I can grab the xml for all members nodes? I's think that

    umbraco.library:GetMember/*

    or

    umbraco.library:GetXmlAll/member

    should do it, but can't find the correct syntax. All help greatfully received

  • Rob Watkins 369 posts 701 karma points
    Feb 24, 2011 @ 15:59
    Rob Watkins
    0

    I can't find any standard function that will give you a member list in XSLT, can anyone else confirm this?

  • Rob Watkins 369 posts 701 karma points
    Feb 24, 2011 @ 16:21
    Rob Watkins
    0

    Incidentally, I am going to need this myself soon, so I wrote a small extension module to do it. 

    This will still hit the database of course, and I imagine it's basically the same as your usercontrol, but I couldn't find a cache of the members anywhere.

    It's extremely simple, just create an extension assembly with this function:

            public static XPathNodeIterator GetAllMemberIDs()
            {
                XmlDocument xd = new XmlDocument();
                XmlNode x = umbraco.xmlHelper.addTextNode(xd, "Members", "");
                foreach (System.Web.Security.MembershipUser user in System.Web.Security.Membership.GetAllUsers())
                {
                    XmlNode n = xd.CreateElement("Member");
                    n.Attributes.Append(umbraco.xmlHelper.addAttribute(xd, "id", Convert.ToString(user.ProviderUserKey)));
                    x.AppendChild(n);
                }
                xd.AppendChild(x);
                return xd.CreateNavigator().Select("/Members");
            }


    ...and add it to your xsltExtensions.config

    This obviously just returns the IDs, so you will have to call GetMember() on the results:

    GetAllMemberIDs()/Member">


    That way any changes to the way umbraco returns members will always be preserved.

  • Tony Kiernan 278 posts 341 karma points
    Feb 25, 2011 @ 13:53
    Tony Kiernan
    0

    Sadly, I've had to flag yours as the right answer.  Thanks anyway.

    Your extension module looks good. I'll give that a go when I get a minute (or the client starts complaining about speeds)

    The more I'm thinking about this, the more I lean towards a simple

    umbraco.library:GetXmlAll()/Members

    These days of multiple contributors and networking I can't help think it would be really useful.

    The fact that the xml is THERE but I can't (easily) get at it is really annoying

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Feb 25, 2011 @ 16:23
    Casey Neehouse
    0

    In the past, the way that I accomplished this was to query the database cmsContentXml table while joining the cmsMember table.  This will give you a dataset of the xml fragments that you can load into an xml document and return.  Not sure if this is still possible in v4.5+

    https://dl.dropbox.com/s/a3byoedd4qp3ghj/members.cs?dl=1

    The above file is a members class that I wrote a long time ago.  It very well may need to be updated to work with 4.5+ 

    (BTW, I cheated an used string concatination to do this class rather than loading the fragments into an xml document properly.  I wrote this at a time when I had an adversion to the ms xml class library..)

     

  • Tony Kiernan 278 posts 341 karma points
    Feb 25, 2011 @ 16:49
    Tony Kiernan
    0

    Thank you, also.

    Is this something we need to raise?  Maybe create a feature request?  

  • Casey Neehouse 1339 posts 483 karma points MVP 2x admin
    Feb 25, 2011 @ 17:02
    Casey Neehouse
    0

    It was talked about in the past, and foregone for the fact that umbraco is extensible and these types of items can easily be created into a package.  At one point, there was an effort started to have a repository of extensions, but it ultimately died.  It may still be on codeplex.

  • Rob Watkins 369 posts 701 karma points
    Feb 28, 2011 @ 10:25
    Rob Watkins
    0

    Having delved a bit more into members (so to speak) I think that because the members are now dealt with purely through the standard ASP.NET membership provider they act a little differently to all the other nodes, which is why the API support doesn't seem to match anything else.

Please Sign in or register to post replies

Write your reply to:

Draft