Get current root node from nested content partial view
Hello, Umbracians.
Sometimes website have a lot of root nodes, in multilingual case for example.
In common, there is no problem to get a current root node with @Model.Ancestor<HomePage>(), but there is when you do it in a partial view of nested content
I'am confused.
How to get a current root node from partial view of nested content?
Get current root node from nested content partial view
Hello, Umbracians.
Sometimes website have a lot of root nodes, in multilingual case for example.
In common, there is no problem to get a current root node with
@Model.Ancestor<HomePage>()
, but there is when you do it in a partial view of nested contentI'am confused. How to get a current root node from partial view of nested content?
Hello Dmitriy
You can get the current page Id with this code:
And then get current root node with code:
Thanks,
Alex
Hi, Alex
Thank you, seems it what I need.
Is it optimal performance way, or has some leaks?
It's fine in performance
Hi,
Would it not be better to use:
Alternative access
IPublishedContent
viaUmbracoHelper
- Umbraco property inUmbracoViewPage
class./Bjarne
is working on a reply...