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 really, really new to Umbraco and razor, but I have to implement new features in Umbraco project.
So I need some advices, because I'm not fully familiar with the syntax and the possibilites. And I do not exactly know how to use the dynamicObjects-Syntax, and I don't even know the correct term for this :)
I want to select all children from all nodes from a certain hierarchy level.
I think about a structure like this:
var list = new List<dynamic>( node1.children.And.node2.children.where());
Does anyone understand my problem and know how I can achieve this? Or do you have some enlightening tutorials about using dynamicObjects
Welcome to our forum!!!
First of all, do not use dynamics with Umbraco, use strongly typed objects if it's possible :)
Read this "Common Pitfalls Tutorial" - https://our.umbraco.org/documentation/reference/Common-Pitfalls/
Thank you :-)
yeah the current project here is full of dynamics. So, I tried to do this in the same way, but thank you for your link and your feedback.
Can you say what happens in Umbraco 8, if IPublishedContent will be removed? I saw this hint in your document. Will I have to rewrite all the code with the current "dynamicObject" - solution ?
I believe Umbraco 8 will remove all dynamic, so it may well require rewriting all these (or, at very least, suffering warnings they are deprecated).
You can find more general docs on strongly-typed querying here: https://our.umbraco.org/documentation/Reference/Querying/IPublishedContent/
I may be misunderstanding, but if you want to select all nodes from a common ancestor then you can use the Descendants. So you could do:
var list = ancestor.Descendants();
You can just get descendants of a particular document type alias by adding the alias as a parameter:
var list = ancestor.Descendants("newsItem");
Thank you this solution works for me :)
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted