Copied to clipboard

Flag this post as spam?

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


  • Marko Ivanovski 14 posts 124 karma points
    Jul 15, 2010 @ 23:06
    Marko Ivanovski
    0

    Using Members properties in Content (editable by Member)

    Hi everyone,

    I'd like to create a Member type with some properties, Name, Address, Phone etc.. and allow members to update their information via a login.

    Furthermore, I'd like to be able to select Members via the Ultimate Picker so I can list their information somewhere on a page.

    I've successfuly created a Member type and assigned it properties, and I can probably figure out how to make their information updatable, but how would I go about selecting member nodes and listing their information?

    Any help would be appreciated.

    Cheers,

    Marko

  • dan 29 posts 53 karma points
    Jul 16, 2010 @ 05:22
    dan
    1

    Hello Marko,
    I found this post that might help you along

    http://our.umbraco.org/forum/developers/api-questions/8828-Get-Properties-from-Member-in-Umbraco-programmatically

    Best

    danielcruger.comhttp://our.umbraco.org/forum/developers/api-questions/8828-Get-Properties-from-Member-in-Umbraco-programmatically

  • Marko Ivanovski 14 posts 124 karma points
    Jul 27, 2010 @ 02:39
    Marko Ivanovski
    0

    Thanks for your help Dan.

    In the end, I ended up using code from another post (which I've lost the link to).

    Either way, here it is.. It's basically a custom extension that selects members by Group Name/Id and allows me to use XSLT for the output.

    using System;
    using System.Data;
    using System.Data.SqlClient;
    using System.Text;
    using System.Xml;
    using System.Xml.XPath;
    using Microsoft.ApplicationBlocks.Data;
    using umbraco.cms.businesslogic.member;

    namespace Custom_Controls.xsltExtensions {

    public class customExt
        {
            public static XPathNodeIterator GetMembersByGroupName(string groupName)
            {
                try
                {
                    return GetMembersByGroupId(MemberGroup.GetByName(groupName).Id);
                }
                catch (Exception ex)
                {
                    XmlDocument xd = new XmlDocument();
                    xd.LoadXml("<response><success>false</success><error>" + ex.Message.ToString() + "</error></response>");
                    return xd.CreateNavigator().Select("/response");
                }
            }
            public static XPathNodeIterator GetMembersByGroupId(int id)
            {
                XmlDocument xd = new XmlDocument();

                try
                {
                    DataSet ds = SqlHelper.ExecuteDataset(
                            new SqlConnection(umbraco.GlobalSettings.DbDSN),
                            CommandType.Text,
                            @"
                                                    Select ccx.xml
                                                    from cmsContentXml ccx
                                                            inner join cmsMember cm
                                                                    on ccx.nodeId = cm.nodeId                                      
                                                            inner join cmsMember2MemberGroup cm2mg
                                                                    on cm.nodeId = cm2mg.Member
                                                    Where cm2mg.MemberGroup = @group
                                            ", new SqlParameter("@group", id.ToString()));

                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("<root count=\"" + ds.Tables[0].Rows.Count + "\">");

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        sb.AppendLine(dr["xml"].ToString());
                    }
                    sb.AppendLine("</root>");

                    xd.LoadXml(sb.ToString());

                    return xd.CreateNavigator().Select("/root");
                }
                catch (Exception ex)
                {
                    xd.LoadXml("<response><success>false</success><error>" + ex.Message.ToString() + "</error></response>");
                    return xd.CreateNavigator().Select("/response");
                }
            }
        }
    }
Please Sign in or register to post replies

Write your reply to:

Draft