I am trying to display a list of members in my front end. So I have created a doc type and template with a heading and a content section (RTE). My members are a part of some groups like IT, Accounts and Sales. I want to display their details: first name, surname, email and phone number in a list. As there are only about 120 employees here it shouldn't be too big!
Any ideas?
I tried:
@foreach(var name in ApplicationContext.Current.Services.MemberService)
{
@name
}
just to try to show the name and then build up to the email and phone number after.
Excellent that spits them out from members! Is it possible to find the members which are of a custom type? I created a few custom types IT member, Accounts member and in there I have a custom tab called Details and here I have properties called First Name, Surname, Email and Phone. Is it possible to pull this data? And alphabetise it?
@foreach (var member in ApplicationContext.Current.Services.MemberService.GetMembersByMemberType("IT Member"))
{
@member.Email
}
At least it compiles, though it returns nothing. I think the foreach is finding the member type and Email is not a type so it returns nothing? Am I along the right path? So to find Email we need to get to the layer below member type as Email is a property of the Details tab on the ITMember type. Phew! Does that make sense?
It was the wrong member type, but it's only finding the standard Child items: Name, Email, Username (Last edited won't work - probably because it's two words!). I'm looking for the custom fields as one of them in phone number....
That's deadly! I forgot one last thing, is there a way to .OrderBy and order them alphabetically according to name? I couldn't find a method in Dennis' list of methods?
How to Display a list of Members
Hi All
I am trying to display a list of members in my front end. So I have created a doc type and template with a heading and a content section (RTE). My members are a part of some groups like IT, Accounts and Sales. I want to display their details: first name, surname, email and phone number in a list. As there are only about 120 employees here it shouldn't be too big!
Any ideas?
I tried:
@foreach(var name in ApplicationContext.Current.Services.MemberService) { @name
}
just to try to show the name and then build up to the email and phone number after.
Am I way off?
Thanks.
Tony
Hi Tony,
Did you try like that :
Hi Alex
Excellent that spits them out from members! Is it possible to find the members which are of a custom type? I created a few custom types IT member, Accounts member and in there I have a custom tab called Details and here I have properties called First Name, Surname, Email and Phone. Is it possible to pull this data? And alphabetise it?
Thanks. :)
Tony
Hi Tony.
I think that you should have a look at the MemberService documentation. You can find the different methods here: https://our.umbraco.org/DOCUMENTATION/Reference/Management-v6/Services/MemberService
Hope this helps,
/Dennis
There few methods in the MemberService:
You can use one of them, and ugly but:
Thanks, Alex
Hi Guys
Thanks for the suggestions
I've tried a few methods like
@foreach (var member in ApplicationContext.Current.Services.MemberService.GetMembersByMemberType("IT Member")) { @member.Email
At least it compiles, though it returns nothing. I think the foreach is finding the member type and Email is not a type so it returns nothing? Am I along the right path? So to find Email we need to get to the layer below member type as Email is a property of the Details tab on the ITMember type. Phew! Does that make sense?
Thanks.
Tony
Tony, maybe it's wrong membertype name ? or alias ?
Alex
It was the wrong member type, but it's only finding the standard Child items: Name, Email, Username (Last edited won't work - probably because it's two words!). I'm looking for the custom fields as one of them in phone number....
Thanks. Tony
Tony, custom fields are retrieving by method GetValue()
Thanks, Alex
Hi Alex
That's deadly! I forgot one last thing, is there a way to .OrderBy and order them alphabetically according to name? I couldn't find a method in Dennis' list of methods?
Thanks.
Tony
Something like that :
Excellent stuff! Sorted! Thanks a lot.
Tony
is working on a reply...