In my other projects, with XSLT, i have a extension from which i can call ie. GetMember('string'), GetMembersAll() ect. Can I reuse it somehow by adding it as a namespace, abit like I do when adding it as an XSLT extension?
You can just access your XSLT extension in exactly the same way that you would in XSLT itself, just replace the ":" with a ",". For example, one of Umbraco's extensions:
Hehe, that's not an error, it's the type name of the result of that function call. You're getting back an XPathSelectionIterator (which would be very convenient if you were using XSLT).
But how about just doing something like this [edit: updated code as per comments below]:
@using umbraco.cms.businesslogic.member
@{
var member = new Member(1129);
var userName = member.Name; //not sure if this is available, could be called something else
var email = member.Email; //not sure if this is available, could be called something else
var someProperty = member.getProperty("myCustomProperty").Value.ToString();
}
Well, if i use the chunk of code you just made, i get this "Error"
Error occured c:\sites\videnbank\macroScripts\634371848915625000_CurrentMember.cshtml(5): error CS0246: The type or namespace name 'Member' could not be found (are you missing a using directive or an assembly reference?)
Now we're allmost there, I'm guessing i need another, since i get this error:
....error CS1061: 'umbraco.cms.businesslogic.member.Member' does not contain a definition for 'GetProperty' and no extension method 'GetProperty' accepting a first argument of type 'umbraco.cms.businesslogic.member.Member' could be found (are you missing a using directive or an assembly reference?)
i just put this code in the Address.cshtml file in ucommerce
@using umbraco.cms.businesslogic.member
@{varmember=newMember(Convert.ToInt32(memberId));varuserName=member.Name;//not sure if this is available, could be called something elsevaremail=member.Email;//not sure if this is available, could be called something elsevaraddressline1=member.getProperty("addressline1").Value.ToString();}
and then i put this value in the address line like this:
What happens if you uncomment the username and email variables? Is it the complete code you have posted above? If so where does the memberId variable get it's value from?
Working with members and Razor
Hey
I created a thread earlier on how to get the name of the current member logge in - no sweat.
Now i wan't to use some custom properties from the member, ie. memberPhone. How do i access those? I've used this to get hold of the other userdata:
@using System.Web.Security
@ {
var member = Membership.GetUser();
}
You are logged in as:
@member.UserName
@member.Email
I have been looking into the Umbraco wiki (http://our.umbraco.org/wiki/how-tos/membership-providers @ Setting a Profile Property) - I've added the field alias to my webconfig, but still no result.
In my other projects, with XSLT, i have a extension from which i can call ie. GetMember('string'), GetMembersAll() ect. Can I reuse it somehow by adding it as a namespace, abit like I do when adding it as an XSLT extension?
Anyone that can help?
/Peter
Oh and btw, I'm running a umb version 4.7
You can just access your XSLT extension in exactly the same way that you would in XSLT itself, just replace the ":" with a ",". For example, one of Umbraco's extensions:
If I try this:
I get this error in the frontend:
MS.Internal.Xml.XPath.XPathSelectionIterator
/Peter
Hehe, that's not an error, it's the type name of the result of that function call. You're getting back an XPathSelectionIterator (which would be very convenient if you were using XSLT).
But how about just doing something like this [edit: updated code as per comments below]:
Allrighty.. Well, I would prefer xslt ;)
Well, if i use the chunk of code you just made, i get this "Error"
Error occured
c:\sites\videnbank\macroScripts\634371848915625000_CurrentMember.cshtml(5): error CS0246: The type or namespace name 'Member' could not be found (are you missing a using directive or an assembly reference?)
Am I missing a namespace?
/Peter
Ah yes sorry, you should add:
Ahh sweet..
Now we're allmost there, I'm guessing i need another, since i get this error:
....error CS1061: 'umbraco.cms.businesslogic.member.Member' does not contain a definition for 'GetProperty' and no extension method 'GetProperty' accepting a first argument of type 'umbraco.cms.businesslogic.member.Member' could be found (are you missing a using directive or an assembly reference?)
Argh, my fault entirely, it's getProperty with lowercase "g".
Sweetness, it works..
Thanks for your time Sebastiaan :)
Hi,
I got a problem about this:
i just put this code in the Address.cshtml file in ucommerce
and then i put this value in the address line like this:
Hi Ezgi and welcome to our :)
What happens if you uncomment the username and email variables? Is it the complete code you have posted above? If so where does the memberId variable get it's value from?
/Jan
Hi Jan, thanks..
Member m = Member.GetCurrentMember();
var city= member.getProperty("city").
Hi Ezgi
As I just wrote in another reply in another post - what version of Umbraco are you using? If 4.11 are you then using MVC?
Looking forward to hearing from you.
/Jan
Hi Jan,
It is 4.9. I guess the Member object does not function properly for my site.. thanks in advance
is working on a reply...