I want to go through each media folder and look for the value of a custom property i've made, "mycustomproperty". How can I do this in the codebehind/api?
I tried
var foundNodes = root.GetDescendantNodes().Where(x => x.GetPropertyAsString("mycustomproperty").Contains(searchString));
And what type of variable is 'root'? I think GetDescendantNodes might only work for Content nodes. Something like this should work for Media (in 4.9.0 with uQuery built in)
var root = new Media(xxxx); var foundNodes = root.GetDescendantMedia().Where(x => x.GetProperty<string>("myValue").Contains(searchString));
Search mediafolders for a property?
I want to go through each media folder and look for the value of a custom property i've made, "mycustomproperty". How can I do this in the codebehind/api?
I tried
var foundNodes = root.GetDescendantNodes().Where(x => x.GetPropertyAsString("mycustomproperty").Contains(searchString));
But it returns null.
Thanks
Pete
Hi,
What version of Umbraco are you using?
And what type of variable is 'root'? I think GetDescendantNodes might only work for Content nodes. Something like this should work for Media (in 4.9.0 with uQuery built in)
Hope this helps,
Tom
Hi Tom
Thanks for the reply. I'm on 4.7.2. I've got uComponents/uQuery installed.
For root I was using:
umbraco.NodeFactory.Node root = umbraco.NodeFactory.Node.GetCurrent();
What do you set for the root? -1? will that make it go through all the media nodes?
Thanks
Not sure how you can start at the media root, but you could try this instead:
-Tom
That did it, many thanks tom.
is working on a reply...