I using Nodefactory to obtain values in a class I'm trying to workout if the .getProperty method has an overload that will allow me to set a value if the property is empty. Also is Nodefactory what I should be using with V7?
Can someone give a short explination on how you on the method .GetProperty(string alias, out bool propertyExist) overload. I understand the alias would be the docucement type field alias however I don't understand the "out bool propertyExist" element.
Thanks in advance
see below for what I am attempting to simplify
var node = new Node(1076);
string preheadercontent = "";
if (!Object.ReferenceEquals(node.GetProperty("preheadercontent"), null))
{
preheadercontent = node.GetProperty("preheadercontent").ToString();
}
template = template.Replace("[preHeaderContent]", preheadercontent);
Hi Damian I'm using version 7, thanks for the suggestion not sure that's what I'm looking for probably my explaination. Can this querying be used in a helper class or just a view?
If the class inherits from an umbraco class or has a the umbraco context - like a controller inherits from SurfaceController - that has the Umbraco helpers.
I thought you were looking to test for the existence of a property and that it had a value.
I don't know where from or how you are trying to access the properties but you can pass the Umbraco context into a class with say the current page using the IPublishedContent.
Nodefactory .GetProperty() overload question
I using Nodefactory to obtain values in a class I'm trying to workout if the .getProperty method has an overload that will allow me to set a value if the property is empty. Also is Nodefactory what I should be using with V7?
Can someone give a short explination on how you on the method .GetProperty(string alias, out bool propertyExist) overload. I understand the alias would be the docucement type field alias however I don't understand the "out bool propertyExist" element.
Thanks in advance
see below for what I am attempting to simplify
Are you using v6 or 7?
If so why dont you just get the IPublishedContent and then use the HasProperty and HasValue methods?
I have typed that code from memory so hopefully it it right. :)
Hi Damian I'm using version 7, thanks for the suggestion not sure that's what I'm looking for probably my explaination. Can this querying be used in a helper class or just a view?
Hi John
If the class inherits from an umbraco class or has a the umbraco context - like a controller inherits from SurfaceController - that has the Umbraco helpers.
This post might help explain it more: http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
I thought you were looking to test for the existence of a property and that it had a value.
I don't know where from or how you are trying to access the properties but you can pass the Umbraco context into a class with say the current page using the IPublishedContent.
Hope this helps and not confused you. :)
Damian
is working on a reply...