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
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.
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+
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..)
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.
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.
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
or
should do it, but can't find the correct syntax. All help greatfully received
I can't find any standard function that will give you a member list in XSLT, can anyone else confirm this?
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:
...and add it to your xsltExtensions.config
This obviously just returns the IDs, so you will have to call GetMember() on the results:
That way any changes to the way umbraco returns members will always be preserved.
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
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
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..)
Thank you, also.
Is this something we need to raise? Maybe create a feature request?
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.
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.
is working on a reply...