Copied to clipboard

Flag this post as spam?

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


  • Brian McNally 16 posts 104 karma points
    May 28, 2014 @ 20:41
    Brian McNally
    0

    Remove top level of breadcrumb in Partial View Macro File

    I've created a simple breadcrumb out of the snippet template. Everything works great but this is a subsection of the site and I don't want the very top level returned in the breadcrumb..I'm sure this is something simple but I can't seem to hunt down a solution.

    the for each statement looks like this

     @foreach (var page in CurrentPage.Ancestors().OrderBy("Level"))
        {
            <li><a href="@page.Url">@page.Name</a> <span class="divider"></span></li>
        }
    

    This returns every level up to the top:

    HOME > LEVEL 1 > LEVEL2 > current page

    What is the best way..or any way...to remove the top level "HOME"

    Thanks

  • Brian McNally 16 posts 104 karma points
    May 28, 2014 @ 21:33
    Brian McNally
    100

    Please disregard, I just found the answer here

     @foreach (var page in CurrentPage.Ancestors().Where("Level >= 2").OrderBy("Level"))
    
  • Mike Chambers 636 posts 1253 karma points c-trib
    Jun 02, 2014 @ 10:48
    Mike Chambers
    0

    looking at the razor cheatsheet...

    @foreach(var page inCurrentPage.Ancestors(2).OrderBy("Level"))

    should also work...

    [http://our.umbraco.org/projects/developer-tools/razor-dynamicnode-cheat-sheet]

Please Sign in or register to post replies

Write your reply to:

Draft