Hi,I can get the currentMember Id using the following - but how do I get member properties - I tried the getProperty method, but that gives an error.my test code:@using umbraco.cms.businesslogic.member.. var member = Member.GetCurrentMember(); <span>@member.Id</span> - works fine<br/> <span>@member.getProperty("Name").Value</span> - breaks the macro<br/>..i tried with ToString() and without .Value - that works, but nothing gets returned.my guess is that properties are not availeble on the member object - but it must be possible to get them somehow - in RazorA tip to an example on how to access the standard member properties and custom properties would be perfect.regardsMichael
What version of Umbraco are you using? If it's 4.11 and you're using MVC razor you perhaps need to do it in another way. The thing is that currently there is macroscript Razor and MVC razor implementations...so what you can do with one implementation may not work with another implementation...
Getting member properties
Hi,I can get the currentMember Id using the following - but how do I get member properties - I tried the getProperty method, but that gives an error.my test code:@using umbraco.cms.businesslogic.member.. var member = Member.GetCurrentMember(); <span>@member.Id</span> - works fine<br/> <span>@member.getProperty("Name").Value</span> - breaks the macro<br/>..i tried with ToString() and without .Value - that works, but nothing gets returned.my guess is that properties are not availeble on the member object - but it must be possible to get them somehow - in RazorA tip to an example on how to access the standard member properties and custom properties would be perfect.regardsMichael
maybe I just found something...
var mymember = Member.GetCurrentMember();
var test = mymember.HasProperty("logo");
that returned true - and I can get the property with mymember.getProperty("logo").Value
that was what i wanted... - happy days :-)
and I can use this as well:
mymember.Email
.Id
and another custom property with the getProperty method
But what about the Name - and other properties?
/Michael
Hi Michael,
You could do something like
strange - that gives an error..
Error loading MacroEngine script
Can you post the whole code ?
i used
var mymember =Member.GetCurrentMember();
var userName = mymember.getProperty("Name").Value.ToString();
But I now use this - and it works:
@using umbraco.cms.businesslogic.member
@{
var mymember = Member.GetCurrentMember();
var userName = mymember.Text;
<span>@userName</span>
}
But I think its strange that properties cant be accessed the same way.
Isnt there some doc. on using Members from Razor (or xsl)
/Mic
Do you have those namespace in your razor file ?
@using umbraco.cms.businesslogic.member
@using System.Web
@using System.Web.Security
only the first one actually... - is that the trick?
Yes it should get you working...
Hi all,
these methods dont work in my address.cshtml file, why do you think so?
thanks
Member m =Member.GetCurrentMember();
var city= member.getProperty("city").
Hi Ezgi
What version of Umbraco are you using? If it's 4.11 and you're using MVC razor you perhaps need to do it in another way. The thing is that currently there is macroscript Razor and MVC razor implementations...so what you can do with one implementation may not work with another implementation...
So it's important to know :)
Looking forward to hearing from you.
/Jan
is working on a reply...