Yes it's related to that Umbraco issue. Currently the only workaround is to first find the node you are looking for and do .GetPropertyValue<DAMP.PropertyEditorValueConverter.Model>(propertyAlias) on that.
Just to follow up, there was one snag with my code above . I needed to cast the imageId to an int first, to prevent the DAMP property editor value converter from running:
var imageId = node.GetPropertyValue(propertyAlias, recursive, 0);
do you know how can I convert Dynamic XML to Damp Model? (using umbraco 6.1.5)
the problem is when I do this page.GetPropertyValue("image",true,null) it returns an object which is dynamic xml and now I need to convert it do damp model?
DAMP recursive properties with Value Converter
When I run the following line:
var dampModel = node.GetPropertyValue<DAMP.PropertyEditorValueConverter.Model>(propertyAlias, recursive, null);
it works fine when recursive = false, it returns a DAMP model object, but when on a child document with recursive = true, it returns null.
Is it because of this Umbraco issue? Is there a workaround that still returns a DAMP.PropertyEditorValueConverter.Model?
Hello,
Yes it's related to that Umbraco issue. Currently the only workaround is to first find the node you are looking for and do .GetPropertyValue<DAMP.PropertyEditorValueConverter.Model>(propertyAlias) on that.
Jeroen
Thanks for the quick reply Jeroen.
Is there a DAMP helper like Umbraco.TypedMedia? In my case it made more sense to do
and cast it to a media item as follows
In this situation I did not need crops but would be nice to cast to be able to cast to a DAMP object from a media ID.
Just to follow up, there was one snag with my code above . I needed to cast the imageId to an int first, to prevent the DAMP property editor value converter from running:
Only then would the TypedMedia call work.
Hi Jeroen,
do you know how can I convert Dynamic XML to Damp Model? (using umbraco 6.1.5)
the problem is when I do this
page.GetPropertyValue("image",true,null)
it returns an object which is dynamic xml and now I need to convert it do damp model?Cheers
Ali
Hello,
I need some more code to see how it currently works before I can help you. Can you paste the page where you are using that part?
Jeroen
the problem is this http://issues.umbraco.org/issue/U4-1958.
so I cannot use
GetPropertyValue<DampModel>("image", true, null)
and in your comment above you mentioned that
"Currently the only workaround is to first find the node you are looking for and do .GetPropertyValue
my question is how to get that node?
the only way I know is to do CurrentPage.GetPropertyValue("image",true) but this returns dynamic XML of the image :
so the quesiton is how to convert this into
DampItem
orDAMP.PropertyEditorValueConverter.Model
I hope this makes sense. I dont have much code to paste here than above.
Two solutions for you:
Snippet
thank you so much Jeavon, the snippet is exactly what I needed
Cheers
Ali
is working on a reply...