It works perfectly, but I don't want to create another property that will be equivalent to Name, and when I Call the Name property that way, it returns empty... You have an idea?
Looking at Umbracos xml the attribute for name is called "nodeName" give that a shot. (note. this is for Umbraco 7 you can check yourself by either looking in the database or in the umbraco.config file, to check what the attribute is called for your version.)
Hey, there is any core member that can help here?!
It sounds like it should be really simple, I just need to know what is the right syntax to get the default property values other than e.g. CurrentPage.Name / CurrentPage.Id ...
Why CurrentPage.GetPropertyValue("Name") or CurrentPage.GetPropertyValue("Id") is empty?!?!
Did you look in the xml of your website to find the object you are trying to access and to check that those values are there? If they are not in there then you might just need to refresh your cache.
Or, have you tried debugging it and looking at the available properties on the object?
One other thing, dont you have to specify a type when using that method. i.e. GetPropertyValue
p.s. If all you need to do is get the name you could always just use
I created a new helper for getting the Name instead of call the helper I wanted,
Its not the best practice- but it works, so I didnt manage to check your reflection solution, but it makes sense...
No worries, I can't see any harm in writing a helper method to query the built in properties before looking in the custom properties. Seems perfectly reasonable to me. If if find anything helpful I will post back with it.
How do I get GetPropertyValue("Name") ??
Hi,
I want to get a node name,
but for some reasons I need to get it like: @page.GetPropertyValue("Name")
[page is DynamicPublishedContent]
and not like: @page.Name
Is it possible?
Hi AvihayBit,
Since I don´t can see your full code snippet you could try this if your are in strongly typed context:
If you are in dynamic context should be able to do like this.
If one of the two example don´t help you, could you please then share your code that you have so far, Then it's much easier to help.
Hope this helps,
/Dennis
Hi Dennis,
Thanks for you help :)
As i wrote above- I cant use @CurrentPage.Name , although page is DynamicPublishedContent... And this is the reason:
I created a GlobalHelper to add a postfix to every property alias, depending on the user's current language.
I call the helper in the template this way:
and this is the helper snippet:
It works perfectly, but I don't want to create another property that will be equivalent to Name, and when I Call the Name property that way, it returns empty... You have an idea?
Looking at Umbracos xml the attribute for name is called "nodeName" give that a shot. (note. this is for Umbraco 7 you can check yourself by either looking in the database or in the umbraco.config file, to check what the attribute is called for your version.)
I have tried that with no success already... returns an empty value...
Hey, there is any core member that can help here?!
It sounds like it should be really simple, I just need to know what is the right syntax to get the default property values other than e.g. CurrentPage.Name / CurrentPage.Id ...
Why CurrentPage.GetPropertyValue("Name") or CurrentPage.GetPropertyValue("Id") is empty?!?!
Did you look in the xml of your website to find the object you are trying to access and to check that those values are there? If they are not in there then you might just need to refresh your cache.
Or, have you tried debugging it and looking at the available properties on the object?
One other thing, dont you have to specify a type when using that method. i.e. GetPropertyValue
p.s. If all you need to do is get the name you could always just use
@Model.Content.Name
There are a few options.
Hi Brian,
Thanks for trying to help,
Yes I took a look at the XML, and it seems that you can get only the properties that you created that way, but not the default. e.g:
I can get the 'title', 'navNam', and all other properties that I added, but not the default properties values that are above them (name, id, date...)
GetProperty() doesnt helps either...
If you read the earlier post you will see why I cant use @Model.Content.Name ....
I am in front of a computer now so I can maybe help a little better. Have you thought about rethinking your methodology?
http://our.umbraco.org/documentation/Reference/Querying/DynamicNode/Properties
The standard built in properties are just c# properties as opposed to "IProperty"s
You could probably use reflection to do what you want ...
http://stackoverflow.com/questions/5508050/how-to-get-a-property-value-based-on-the-name
... although I would recommend re-factoring.
Thanks Brian,
I created a new helper for getting the Name instead of call the helper I wanted, Its not the best practice- but it works, so I didnt manage to check your reflection solution, but it makes sense...
Thanks again!
No worries, I can't see any harm in writing a helper method to query the built in properties before looking in the custom properties. Seems perfectly reasonable to me. If if find anything helpful I will post back with it.
is working on a reply...