Umbraco 7 how to get data type of document property
Hey guys I have a problem. Currently I am trying to get some code working that can add a child node to specific pages when they have a specific Document Type.
To do this I want to be able to add a custom Data Type as a property to a Document Type to "flag" it to create a child node on save. However, I don't seem to be able to get the Data Type from the code behind, because the PropertyType Property of the Property class in Umbraco.Core.Models is not public.
I want to avoid hardocded values in the code behind as much as possible so I can get a setup that is as flexible as possible, so I really want to be able to use the Data Type. So how can I access the Data Type of a given property?
Below is an image of what I have so far. Basically I want to check if any property of the current node has the correct Data Type.
EDIT: After further searching I found the answer myself. IContent also contains a seperate IEnumerable that contains all the available PropertyTypes on a given node, so my problem is solved.
Happy to see you managed to figure out how to solve your issue.
Could you post your "EDIT" as a new post? Then I'll be able to mark your answer as the solution so others can jump straight to it if they face the same issue. Right now it's not obvious that you figured it out.
After further searching I found the answer myself. IContent also contains a seperate IEnumerable that contains all the available PropertyTypes on a given node, so my problem is solved.
Umbraco 7 how to get data type of document property
Hey guys I have a problem. Currently I am trying to get some code working that can add a child node to specific pages when they have a specific Document Type.
To do this I want to be able to add a custom Data Type as a property to a Document Type to "flag" it to create a child node on save. However, I don't seem to be able to get the Data Type from the code behind, because the PropertyType Property of the Property class in Umbraco.Core.Models is not public.
I want to avoid hardocded values in the code behind as much as possible so I can get a setup that is as flexible as possible, so I really want to be able to use the Data Type. So how can I access the Data Type of a given property?
Below is an image of what I have so far. Basically I want to check if any property of the current node has the correct Data Type.
EDIT: After further searching I found the answer myself. IContent also contains a seperate IEnumerable that contains all the available PropertyTypes on a given node, so my problem is solved.
Hi Dave
Happy to see you managed to figure out how to solve your issue.
Could you post your "EDIT" as a new post? Then I'll be able to mark your answer as the solution so others can jump straight to it if they face the same issue. Right now it's not obvious that you figured it out.
Happy coding btw! :)
/Jan
After further searching I found the answer myself. IContent also contains a seperate IEnumerable that contains all the available PropertyTypes on a given node, so my problem is solved.
is working on a reply...