I have a multilingual multisite that currently has two home nodes - one is named "Home" and lives at the root of the site "/" - the other is named "Home-DE" and lives at "/de/". I have a partial view for my header navigation that contains a logo for the site that links back to the home page. I have tried many solutions to link that logo to the "/de/" root when you are on the de site - but all I seem to be able to grab is root "/" so the logo always links to the English site. How do I reference the root of the node that my page is currently under?
Here is my current code:
@{
UmbracoHelper rootHelper = new UmbracoHelper(UmbracoContext.Current);
var root = rootHelper.TypedContentAtRoot().FirstOrDefault(x => x.DocumentTypeAlias == "Home");
var rootUrl = root.Url;
}
Reference Root Node URL in Multilingual Multisite
I have a multilingual multisite that currently has two home nodes - one is named "Home" and lives at the root of the site "/" - the other is named "Home-DE" and lives at "/de/". I have a partial view for my header navigation that contains a logo for the site that links back to the home page. I have tried many solutions to link that logo to the "/de/" root when you are on the de site - but all I seem to be able to grab is root "/" so the logo always links to the English site. How do I reference the root of the node that my page is currently under?
Here is my current code:
and I am referencing it like this:
Hi Michael
Try this code:
.Site - returns current root node.
/Alex
Thank you, Alex! That did the trick - you are a life saver!
You are welcome, Michael, have a great day!
/Alex
is working on a reply...