Display All Members - With links to Public Profile Page
Hello Everyone! I am looking to create an employee directory page. I am using v4.7 of Umbraco. Im still young to Umbraco so the more detail intruction provided the better.
I want to list all of my members in a paginated list within my "Directory.aspx" page. I would like to show the Member Name and a few other basic items like this:
The names would be links to a "page" (http://mysite.com/directory/MyName) that showed all of the members information (such as bio, interests, ect). I was reading this post: http://bit.ly/gfL1BX which seems to point how to create the dynamic individual profile pages, but I haven't been able to get that far.
Is there a package, or anything better than using "Members" to set something like this up? Does anyone use XSLT to accomplish something like this that they wouldn't mind sharing?
<umbraco:Macro runat="server" language="cshtml"> @using umbraco.cms.businesslogic.member @{ var memberId= HttpContext.Current.Request.QueryString["id"]; } @if(memberId != null) { var member = new Member(Convert.ToInt32(memberId)); var userName = member.Text; //not sure if this is available, could be called something else //var someProperty = member.getProperty("myCustomProperty").Value.ToString(); <h2>user @userNameh2> <div>fill with other propertiesdiv> } else { var members = Member.GetAll; <span>Listspan> foreach(var item in members){ <h1>@item.LoginNameh1> <span><a href="[email protected]">@item.Emaila>span> //var someProperty = item.getProperty("myCustomProperty").Value.ToString(); } }
I think I have to write it differently depending on the status of the page.. (item.getProperty vs member.getProperty)... this is working for me:
<umbraco:Macro runat="server" language="cshtml"> @using umbraco.cms.businesslogic.member @{ var memberId= HttpContext.Current.Request.QueryString["id"]; } @if(memberId != null) { var member = new Member(Convert.ToInt32(memberId)); var userName = member.Text; //not sure if this is available, could be called something else //var someProperty = member.getProperty("myCustomProperty").Value.ToString(); <h2>user @userName</h2> <div>fill with other properties</div> var phone = member.getProperty("phoneNumber").Value.ToString(); <span>@phone</span> } else { var members = Member.GetAll; <span>List</span> foreach(var item in members){ <h1><a href="[email protected]">@item.Text</a></h1> <span>@item.Email</span> <span>@item.Id</span> var phone = item.getProperty("phoneNumber").Value.ToString(); <span>@phone</span> } }
</umbraco:Macro>
Now I just have to add in all of the other values and get it styled up. That puts me one step closer.. Thank you Damiaan
I would like that entire section to dissapear if the member doesn't have a personal website.
2.) I have checkboxes and dropdown lists in my members admin area. When I pull out that information onto my website I get the numberic value (87) for the item picked and not the text value (Dean's Office). What do I need to add to fix that?
Well I have a few datatypes that are checklist boxes where a user can check off a few of my pre-written options. and I would like the results to display like: "Option 1, Option 2"... but right now I am getting "87, 91"
Pretty much the same deal with the dropdown list datatype. Where the member can select the building that they are located in. And I want the results to look like this: "Building XYZ", but I am only getting "99"
Oh ok. To be honest, I never used prevalues. So maybe someone else can catch up here.
As far as i'm aware, you have the values as a string. So you will have to split them up into an ary and loop them manually. After that you can use the GetPreValueAsString for every id... I'am typing this without code editor and without testing. So forgive me any mistakes.
@{ foreach(var id in MyIntsToShow.Split(',')) { var myStringValue = umbraco.library.GetPreValueAsString(Convert.ToInt32(id)); <li>@myStringValue li> } }
So this is what it could look like in Razor. But certain that there must be xslt solutions for this too. Good luck!
Edit: tested the code and now it works (if the 'MyIntsToShow' string is a comma separated list of numbers)
So in my admin area for the members I have a tab called basic info and I have this departments section in it.
Then in my template I call the varible basically like this..
var departments = item.getProperty("facultyDepartments").Value.ToString(); <span>@departments</span>
but when my HTML page renders out I get this result:
the (87,70) should read out like Dean's Office, Legal Studies
You can see the same issue in the image above with (Location: 88) but this is a dropdown list. But same concept. I would think I would change the way I get the value of the property..
var departments = @item.getProperty("facultyDepartments").Value.ToString().Split(new[],',');
@foreach(var id in departartments) {
<li>@umbraco.library.GetPreValueAsString(Convert.ToInt32(id));</li>
}
@{var departments =@item.getProperty("facultyDepartments").Value.ToString().Split(new[],','); foreach(var id in departartments){ <li>@umbraco.library.GetPreValueAsString(Convert.ToInt32(id));</li> }}
You don't need an extra @-sign before the item variable because you started with @{ ...
@{var departments =item.getProperty("facultyDepartments").Value.ToString().Split(new[],','); foreach(var id in departartments){ <li>@umbraco.library.GetPreValueAsString(Convert.ToInt32(id));</li> }}
Thanks for all your work guys.. Im still not getting past the error... so just to make sure I am dropping everything in correctly here is what I got so far..
The image below shows where I currently am. I call the facultyDepartments variable, and only get it to call the IDs, not the titles.
Then I change @departments with the code that you have provided and get the following result:
If I am missing something obvious Im sorry, but I figured these screen shots might help in pointing it out. Thanks again for looking into this issue with me.
Ok so I was looking at your link..I set up this code..
@{ var departartments = "87,70"; foreach(var id in departartments.Split(',')) { var memberDepartments = umbraco.library.GetPreValueAsString(Convert.ToInt32(id)); <li>@memberDepartments</li> } }
Which is working to call the values correctly, (Dean's office, legal studies) however you can see that I have hardcoded those in there and thus is showing them for all my members.. I need to swap out:
var departartments = "87,70";
with something that pulls the code for only that specific user..like:
var departments = item.getProperty("facultyDepartments").Value.ToString();
but I haven't gotten that to work yet.... ALMOST THERE :-)
Well I was hoping that I would be able to convert that working example to work for a situation that only has 1 value but no luck so far. I have some values that come from a dropdown list.. but I guess it's a little different somehow
I am able to hardcode it in there:
@{ var buildingLocation = "88"; foreach(var id in buildingLocation.Split(',')) { var memberLocation = umbraco.library.GetPreValueAsString(Convert.ToInt32(id)); @memberLocation } }
but haven't been able to get it dynamically called using:
Logically I would think that the code below would work for me.
@{ var buildingLocation = item.getProperty("facultyBuildingLocation").Value.ToString(); foreach(var id in buildingLocation.Split(',')) { var memberLocation = umbraco.library.GetPreValueAsString(Convert.ToInt32(id)); @memberLocation } }
But I'm starting to think that because the variable "facultyBuildingLocation" comes from a single selection dropdown list in my members section, that "Split" or the "foreach" command might be throwing me an issue that is preventing me from calling the data correctly.I were to swtich out ("facultyBuildingLocation") with ("facultyDepartments") it works perfectly. So I would think there has to be something different in the way I am supposed to call multiple values from a checkbox selection v.s. a single selection from a dropdown list.
I've take the members directory pretty far in the last 2 months and been able to populate it with all kinds of informaiton. But now I'm trying to add searching to it and not having a lot of luck yet. I thought I would post back here and see fi either of you two might have some thoughts on it since you are both the most familiar with this little project.
I am very new to umbraco and i am developing a site wich was created by someone else couple of months ago. I too need to do something like FarmFreshCode here.
I need to create a directory which has all the employees information like title, dept, email etc and the name of the employee would be clickable link which would take to the full profile of the employee page. I have no idea how to achieve this :(. My basic questions rightnow are:
1] I was able to import all the members into database using CMS Import, but how do i display the members on directory page ?
2] How do i create a empty profile page and use it pull data about member from database ?
I really would appreciate if anyone could give me a starting point or any reference material as where to begin from....
I'm trying to create a Members list using some things I've found on this topic. However, I'm trying to use a profile property of "headshot." I can get the image to appear on the single Member profile, but I am wanting to create a full list (the "else" portion) and everytime I use the .getProperty("headshot").Value.ToString(); I get a front-end error message.
I'm using umbraco 4.11.3
Any help would be appreciated.
Note: Using the same line of code works on the individual profile pages.
Display All Members - With links to Public Profile Page
Hello Everyone! I am looking to create an employee directory page. I am using v4.7 of Umbraco. Im still young to Umbraco so the more detail intruction provided the better.
I want to list all of my members in a paginated list within my "Directory.aspx" page. I would like to show the Member Name and a few other basic items like this:
The names would be links to a "page" (http://mysite.com/directory/MyName) that showed all of the members information (such as bio, interests, ect). I was reading this post: http://bit.ly/gfL1BX which seems to point how to create the dynamic individual profile pages, but I haven't been able to get that far.
Is there a package, or anything better than using "Members" to set something like this up? Does anyone use XSLT to accomplish something like this that they wouldn't mind sharing?
Thanks in advance.
Hi something to start with in your template
check also http://our.umbraco.org/wiki/how-tos/membership-providers
@Damiaan Ok, this seems like it will be a great starting point for me.
1.) I haven't been able to pull in my custom properties yet. For example one that has the alias of "phoneNumber". What would I need to do that?
Hi,
I guess (never done it on Members), that you could use this :
var someProperty = member.getProperty("aliasOfYourProperty").Value
<span>@someProperty</span>
I think I have to write it differently depending on the status of the page.. (item.getProperty vs member.getProperty)... this is working for me:
Now I just have to add in all of the other values and get it styled up. That puts me one step closer.. Thank you Damiaan
Things are working really well, but I have come to 2 questions:
1.) How do I make entire DIVs dissapear if a member doesn't enter information for that section? For example:
I would like that entire section to dissapear if the member doesn't have a personal website.
2.) I have checkboxes and dropdown lists in my members admin area. When I pull out that information onto my website I get the numberic value (87) for the item picked and not the text value (Dean's Office). What do I need to add to fix that?
The first shouldn't be too hard.
The second depends a on your used datatype.
Well I have a few datatypes that are checklist boxes where a user can check off a few of my pre-written options. and I would like the results to display like: "Option 1, Option 2"... but right now I am getting "87, 91"
Pretty much the same deal with the dropdown list datatype. Where the member can select the building that they are located in. And I want the results to look like this: "Building XYZ", but I am only getting "99"
Oh ok. To be honest, I never used prevalues. So maybe someone else can catch up here.
As far as i'm aware, you have the values as a string. So you will have to split them up into an ary and loop them manually. After that you can use the GetPreValueAsString for every id... I'am typing this without code editor and without testing. So forgive me any mistakes.
So this is what it could look like in Razor. But certain that there must be xslt solutions for this too. Good luck!
Edit: tested the code and now it works (if the 'MyIntsToShow' string is a comma separated list of numbers)
So in my admin area for the members I have a tab called basic info and I have this departments section in it.
Then in my template I call the varible basically like this..
but when my HTML page renders out I get this result:
the (87,70) should read out like Dean's Office, Legal Studies
You can see the same issue in the image above with (Location: 88) but this is a dropdown list. But same concept. I would think I would change the way I get the value of the property..
Hi,
what happens if you replace the <span> with :
I just get an error: "Error loading Razor Script - Input string was not in a correct format."
and what about
So I changed it to this..
and I got a list like this..
Which is weird because my selections are "Deans List" and "Legal Studies" no idea where that is pulling from
Try this:
var departments = @item.getProperty("facultyDepartments").Value.ToString().Split(new[],','); @foreach(var id in departartments) { <li>@umbraco.library.GetPreValueAsString(Convert.ToInt32(id));</li> }
error'd on me:
Try this:
@{var departments = @item.getProperty("facultyDepartments").Value.ToString().Split(new[],',');
foreach(var id in departartments) {
<li>@umbraco.library.GetPreValueAsString(Convert.ToInt32(id));</li>
}}
ha yeah, I tried that right after and still got the same error. But nice to see my "guess" wasn't crazy... although it didnt work.. :-(
You don't need an extra @-sign before the item variable because you started with @{ ...
@{var departments = item.getProperty("facultyDepartments").Value.ToString().Split(new[],',');
foreach(var id in departartments) {
<li>@umbraco.library.GetPreValueAsString(Convert.ToInt32(id));</li>
}}
Thanks for all your work guys.. Im still not getting past the error... so just to make sure I am dropping everything in correctly here is what I got so far..
The image below shows where I currently am. I call the facultyDepartments variable, and only get it to call the IDs, not the titles.
Then I change @departments with the code that you have provided and get the following result:
If I am missing something obvious Im sorry, but I figured these screen shots might help in pointing it out.
Thanks again for looking into this issue with me.
Looks like your doing exactly this: http://our.umbraco.org/wiki/reference/umbracolibrary/getprevalueasstring
Instead of doing Convert.ToInt32(prevalueid)
Try casting it like (int)prevalueid
Ok so I was looking at your link..I set up this code..
Which is working to call the values correctly, (Dean's office, legal studies) however you can see that I have hardcoded those in there and thus is showing them for all my members.. I need to swap out:
with something that pulls the code for only that specific user..like:
but I haven't gotten that to work yet.... ALMOST THERE :-)
Remove ToString() and see what happens
OK GOT IT!
You had to re-set departments? that's odd.
Well I was hoping that I would be able to convert that working example to work for a situation that only has 1 value but no luck so far. I have some values that come from a dropdown list.. but I guess it's a little different somehow
I am able to hardcode it in there:
but haven't been able to get it dynamically called using:
item.getProperty("facultyBuildingLocation").Value.ToString();
Logically I would think that the code below would work for me.
But I'm starting to think that because the variable "facultyBuildingLocation" comes from a single selection dropdown list in my members section, that "Split" or the "foreach" command might be throwing me an issue that is preventing me from calling the data correctly.I were to swtich out ("facultyBuildingLocation") with ("facultyDepartments") it works perfectly. So I would think there has to be something different in the way I am supposed to call multiple values from a checkbox selection v.s. a single selection from a dropdown list.
Hello Damiaan and Daniel Bardi
I've take the members directory pretty far in the last 2 months and been able to populate it with all kinds of informaiton. But now I'm trying to add searching to it and not having a lot of luck yet. I thought I would post back here and see fi either of you two might have some thoughts on it since you are both the most familiar with this little project.
You can check out the youtube video I made here: http://bit.ly/r5ruSX
and see where I have posted on the forum already here: http://bit.ly/mOVfsM
If you have any thoughts on how to add search to this I would greatly appreciate it.
Thanks in advance.
hi everyone,
I am very new to umbraco and i am developing a site wich was created by someone else couple of months ago. I too need to do something like FarmFreshCode here.
I need to create a directory which has all the employees information like title, dept, email etc and the name of the employee would be clickable link which would take to the full profile of the employee page. I have no idea how to achieve this :(. My basic questions rightnow are:
1] I was able to import all the members into database using CMS Import, but how do i display the members on directory page ?
2] How do i create a empty profile page and use it pull data about member from database ?
I really would appreciate if anyone could give me a starting point or any reference material as where to begin from....
-ashwini.
I'm trying to create a Members list using some things I've found on this topic. However, I'm trying to use a profile property of "headshot." I can get the image to appear on the single Member profile, but I am wanting to create a full list (the "else" portion) and everytime I use the .getProperty("headshot").Value.ToString(); I get a front-end error message.
I'm using umbraco 4.11.3
Any help would be appreciated.
Note: Using the same line of code works on the individual profile pages.
is working on a reply...