I've been using this Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1) for dynamically generating an XML sitemap for my umb sites. But, I just realized today that it's getting everything but the home page. My site tree is like this:
-Home
--About
--Contact
--So On
--So Forth
--404
--Sitemap
Right now, the above code returns everything from "About" on down. How do I include the Home page? I've seen a bunch of stuff on Stackoverflow, but nothing I tried there worked. For what it's worth I'm getting everything but the Home page on both Umb 6 and 7.
Model.Site() or Model.Content.Site() (depending on what view you are inheriting in your razor page)
will return the root of the current site.
but these are just a wrapper for Model.Content.AncestorOrSelf(1), so it might be worth checking other bits of logic on the page too, to see if you are dealing with the first item in the list when building the sitemap.
How to find the root note in umb 6 & 7
I've been using this
Umbraco.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1)
for dynamically generating an XML sitemap for my umb sites. But, I just realized today that it's getting everything but the home page. My site tree is like this:-Home --About --Contact --So On --So Forth --404 --Sitemap
Right now, the above code returns everything from "About" on down. How do I include the Home page? I've seen a bunch of stuff on Stackoverflow, but nothing I tried there worked. For what it's worth I'm getting everything but the Home page on both Umb 6 and 7.
Hi
in a template / view
Model.Site()
orModel.Content.Site()
(depending on what view you are inheriting in your razor page)will return the root of the current site.
but these are just a wrapper for
Model.Content.AncestorOrSelf(1)
, so it might be worth checking other bits of logic on the page too, to see if you are dealing with the first item in the list when building the sitemap.is working on a reply...