Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • bh 408 posts 1395 karma points
    Oct 13, 2017 @ 15:19
    bh
    0

    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.

  • Kevin Jump 2310 posts 14694 karma points MVP 7x c-trib
    Oct 13, 2017 @ 15:46
    Kevin Jump
    0

    Hi

    in a template / view

    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.

Please Sign in or register to post replies

Write your reply to:

Draft