I have the following structure in my back office and when on the home node I would like to access the Carousel Repository node and display its contents.
--Home (Level 1)
----Node (level 2)
----Node (level 2)
--Carousel Repository (Level 1)
I am able to do it using
@{ var CarouselRepository = Umbraco.Content(1063); }
But i would like to get it by docTypeAlias rather than use an ID
Can someone please help im having a dull moment :)
Thanks for the reply mate. Im still getting an error with that code.
I think i am getting this error because i am on the home page and the parent is null i just need to get the carouselRepository page which is at the same level.
FYI i am using a partial view on the homepage template.
Accessing a same level node in Razor
Hi All,
I have the following structure in my back office and when on the home node I would like to access the Carousel Repository node and display its contents.
--Home (Level 1)
----Node (level 2)
----Node (level 2)
--Carousel Repository (Level 1)
I am able to do it using
But i would like to get it by docTypeAlias rather than use an ID
Can someone please help im having a dull moment :)
Many thanks
Paul
Hi Paul
Had that same dull moment earlier - it wasn't as obvious as I thought.
Work is my docType alias, then just q.Title to get property of "Title".
Work is actually on the 2nd Level, hence the .First() to get first child.
Anyhow, sure you can see what you need from here.
Cheers
Gary
Hi Gary,
Thanks for the reply mate. Im still getting an error with that code.
I think i am getting this error because i am on the home page and the parent is null i just need to get the carouselRepository page which is at the same level.
FYI i am using a partial view on the homepage template.
Think im getting tired ;)
Cheers
Paul
Try this:
I always prefer
Model.Content
overCurrentPage
, as the latter is dynamic and you don't get intellisense.By the way, you also don't need to add an at sign (@) before an expression or variable unless you intend to output that variable or expression.
Hi All
Sorry missed your reply.
Problem is - - you have no top node, all are at the same level, therefore you have no descendants or siblings.
Top Node (domain) ----Home ----Carousel Repository
Will give you parent (Top Node) and Home and Carousel as descendants / children.
Tiredness gets to us all.
Cheers
Gary
is working on a reply...