Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to get the id's of the nodes selected using the Multinode Tree Picker
Currently this is what I have
var Result = node.GetPropertyValue("propertyName").ToString()
Result ends up being.
The Id's are in the result, but this method is returning xml. as well,
I'm using umbraco 6 - I don't really want to have to start extracting the number from the string, or covert it in to a xml document....
is there a way I can just force umbraco to give me CSV so in this example I get
Found the answer to my question so I just thoght I'd post the answer just in case someone else has the same problem.
On the definition of my Multinode Tree Picker, there is a option of how the values are stored.
If you select CSV - problem solved.
See screen shot
Umbraco core property convertors are your friend https://our.umbraco.org/projects/developer-tools/umbraco-core-property-value-converters/
So you can then do
IEnumerable<IPublishedContent> typedMultiNodeTreePicker = Model.Content.GetPropertyValue<IEnumerable<IPublishedContent>>("propertyName");
foreach (IPublishedContent item in typedMultiNodeTreePicker)
It will convert everything for you.
I only needed the id's so changing the data-type definition worked quite well for me.
I was aware of the GetPropertyValue<> conversion thing, but in my mind I had never thought about coveting to IPublished content, I just used it to do things like bool, and int, but yes your right!
That's one for the tool box... ill be using that in future!
Is there any way to get the Ids without getting the IPublishedContent objects?
I would like to do something like this, but this does not work for me:
var Result = node.GetPropertyValue<IEnumerable<int>>("propertyName")
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted