Copied to clipboard

Flag this post as spam?

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


  • Rasmus Pedersen 8 posts 28 karma points
    Nov 08, 2011 @ 16:18
    Rasmus Pedersen
    0

    XSLT and Members

    I'm using Umbraco 4.7

    I need a memberlist displayed in frontend, preferably using XSLT

    I can't seem to find anything premade that's current and working with 4.7, have I gone blind?

    Thank you

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Nov 08, 2011 @ 21:14
    Jan Skovgaard
    0

    Hi Rasmus

    You have not gone blind. There is no default XSLT extension that let's you do what you want to.

    If you have the neccesary skills I think it should be fairly easy to write an XSLT extension yourself. Otherwise I think you should look into installing uComponents where there is a "GetMembersByGroupName()", which could maybe what you need?

    /Jan

  • Rasmus Pedersen 8 posts 28 karma points
    Nov 08, 2011 @ 23:04
    Rasmus Pedersen
    0

    Well, I need more than just the names... I need them for searching.

    Anyway, I just wrote this class to generate the XML.

     using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Xml;
    using System.Xml.XPath;
    using System.Xml.Linq;
    using umbraco.cms.businesslogic.member;
    using System.Web.Security;
    
    namespace MemberControls
    {
        public class MemberExtension
        {
            public static string AllMembersByGroup(){
                IEnumerable<Member> members = umbraco.cms.businesslogic.member.Member.GetAllAsList();
                var xdoc = new XDocument();
                var xMembers = new XElement("members");
                xdoc.Add(xMembers);
                foreach (Member member in members)
                {
                    var user = new XElement("member","");
                    foreach (umbraco.cms.businesslogic.property.Property prop in member.getProperties)
                    {
                        user.Add(new XElement(prop.PropertyType.Alias, prop.Value));
                    }
    
                    xMembers.Add(user);
    
                }
                return xdoc.ToString();
            }
        }
    }

    I know it uses deprecated code, but unsure how else to do it. Any pointers?

    And yeah, it does get all the users, but hat's just a minor bump in the road. 

  • Rasmus Pedersen 8 posts 28 karma points
    Nov 08, 2011 @ 23:18
    Rasmus Pedersen
    0

    New and better class, less code, not using deprecated stuff.

    This is what I need.
    Just need to make the XSLT extension now.

     

     using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Xml;
    using System.Xml.XPath;
    using System.Xml.Linq;
    using umbraco.cms.businesslogic.member;
    using System.Web.Security;
    
    namespace MemberControls
    {
        public class MemberExtension
        {
            public static string AllMembersByGroup(){
                IEnumerable<Member> members = umbraco.cms.businesslogic.member.Member.GetAllAsList();
    
                XmlDocument xdoc = new XmlDocument();
                XmlElement xMembers = xdoc.CreateElement("members");
    
                xdoc.AppendChild(xMembers);
                foreach (Member member in members)
                {
                    XmlNode xmember = member.ToXml(xdoc, true); ;
                    xMembers.AppendChild(xmember);
    
                }
                return xdoc.OuterXml;
            }
        }
    }
  • Rasmus Pedersen 8 posts 28 karma points
    Nov 08, 2011 @ 23:27
    Rasmus Pedersen
    0

    ACK!

    The new "improved" class doesn't do the job completely. It omits custom datatypes with multiple elements, checkboxlists, dropdownlists etc.

    I have to stick with the old deprecated, there I get big ole' dirty data. but it has what I need.

     This is from the first code I wrote.

    <customdatatypecheckboxlist>9,10,12,13,14,</customdatatypecheckboxlist>

     

    The second codeblock returns this.

    <customdatatypecheckboxlist><![CDATA[]]></customdatatypecheckboxlist>

    Oh well... enjoy if you need it.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies