If you are using a dynamic node you can just @MyDynamicNode.MyPropertyAlias and access it like that, or if you are using a regular Node, then you would do @MyNode.GetProperty("MyPropertyAlias")
It's something like that! Hope I've pointed you in the right direction at least! :)
Just wanted to followup on this as I've finally got a solution in place, hopefully this helps someone who lands in the same boat as I have been the past few days.
So my issue has been that the Properties list present on nodes returned from Umbraco.Content(whatever).Children contained property values and their respective aliases but did not contain the actual name/label of the property.
I found that a lookup must be performed on the node's content type, the result here was an object that contained both the alias and name!
Here's the relevant code that's worked for me. Note: I opted to create a dictionary to output my property names where needed.
int ContentTypeId; // ex: [YourUmbracoNode].ContentType.Id
var cts = ApplicationContext.Current.Services.ContentTypeService;
var ct = cts.GetContentType(ContentTypeId);
Dictionary<string, string> propMap = new Dictionary<string, string>();
foreach (var propertyType in ct.PropertyTypes)
{
propMap.Add(propertyType.Alias, propertyType.Name);
}
Hopefully this helps someone out there.
Credit:
Hobbled together from these other, related, threads:
Get property name
Hi,
Does anyone know how to get the Name (not alias) of a property in Razor?
thanks,
Matt
Hi Matt,
If you are using a dynamic node you can just @MyDynamicNode.MyPropertyAlias and access it like that, or if you are using a regular Node, then you would do @MyNode.GetProperty("MyPropertyAlias")
It's something like that! Hope I've pointed you in the right direction at least! :)
Oops looks like I've misread your post!
It's just Name, e.g.
DynamicModel.Children.First().ContentType.Name
If you want to see all of them, you could try:
This forum really doesn't like you pasting code in
This doesn´t work when you need Name of Property
prop.Name doesn´t work in this case, but name is written somewhere in database. Can i uncover this field to be able to display it?
Howdy Zedna -- Did you have any success in accessing a property's name? I'm having the same issue...
So weird that it's not included with the actual property...
Just wanted to followup on this as I've finally got a solution in place, hopefully this helps someone who lands in the same boat as I have been the past few days.
So my issue has been that the Properties list present on nodes returned from Umbraco.Content(whatever).Children contained property values and their respective aliases but did not contain the actual name/label of the property.
I found that a lookup must be performed on the node's content type, the result here was an object that contained both the alias and name!
Here's the relevant code that's worked for me. Note: I opted to create a dictionary to output my property names where needed.
Hopefully this helps someone out there.
Credit:
Hobbled together from these other, related, threads:
is working on a reply...