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 a specific content node with a specific document type. This content node is a root node and I do have 2 other nodes at root level.
This is my hierarchy in the backend content section:
How do I get the data from the Details node in a template connected to the EN node using razor?
Hi Yannick, you can use .Siblings(), and if you are not at level 1, you can go up at first with .Root():
var detailsNode = Model.Root().Siblings().FirstOrDefault(x => x.ContentType.Alias == "docTypeAlias");
Replace the string "docTypeAlias" with the alias of your Details Node.
Best, Sören
Thanks Sören,
works perfectly!
Very useful. Saved my life as I had to find a root within a partial model and couldn't use UmbracoHelper
For Umbraco 8 you can try:
var rootNode = Umbraco.Web.Composing.Current.UmbracoHelper.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == "docTypeAlias");
Model.Root().SiblingsAndSelf() => it gets all root pages
Model.Root() => it gets just current page root
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Get root node
I'm trying to get a specific content node with a specific document type. This content node is a root node and I do have 2 other nodes at root level.
This is my hierarchy in the backend content section:
How do I get the data from the Details node in a template connected to the EN node using razor?
Hi Yannick, you can use .Siblings(), and if you are not at level 1, you can go up at first with .Root():
Replace the string "docTypeAlias" with the alias of your Details Node.
Best, Sören
Thanks Sören,
works perfectly!
Very useful. Saved my life as I had to find a root within a partial model and couldn't use UmbracoHelper
For Umbraco 8 you can try:
Model.Root().SiblingsAndSelf() => it gets all root pages
Model.Root() => it gets just current page root
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.