Copied to clipboard

Flag this post as spam?

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


  • Rob 5 posts 55 karma points
    Jan 21, 2013 @ 17:18
    Rob
    0

    When building breadcrumb two different levels get the same node.Level value

    I have this weird problem. I'll try to explain.

    I'll start with my site's content tree:

    Content
        - Home
            - Second
                - Third
                    - Three
                    - Three
                - Third
                    - Three
            - Second
                - Third
                - Third
                    - Three
                    - Three
                    - Three
                        - Fourth
                        - Fourth
            - Second
            - Second

    The razor code in breadcrumb.cshtml:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    <ul class="nav breadcrumb-nav">
        @foreach(var node in Model.Ancestors().Where("Visible"))
        {
            <li class="breadcrumb__item">
                @node.Name (@node.Level>
            </li>
        }
          <li class="breadcrumb__item last">
              @Model.Name (@Model.Level)
          </li>
    </ul>

    This is a very simple breadcrumb navigation.

    The problem is that this outputs as the following:

    <ul class="nav breadcrumb-nav">
        <li class="breadcrumb__item">Home(1)</li>
        <li class="breadcrumb__item">Second(2)</li>
        <li class="breadcrumb__item">Third(2)</li>
        <li class="breadcrumb__item last">Fourth(3)</li>
    </ul>

    See the problem?

    I output the level after the name, and i get level (2) for both the second and third items.

    Some more info:

    • umbraco v 4.11.1 (Assembly version: 1.0.4715.27659)
    • windows 7

  • Mike Chambers 636 posts 1253 karma points c-trib
    Jan 21, 2013 @ 17:21
    Mike Chambers
    0

    I found this with u4.10 that moving documents in the tree didn't update the level in the db.. I had to go in manually and correct

    since updating to 4.11.1 I've not seen that, I think is was an issue that was fixed around moving items....

    Maybe you moved some items prior to the update to 4.11???

     

  • Rob 5 posts 55 karma points
    Jan 21, 2013 @ 17:36
    Rob
    0

    Nope, my first install of Umbraco was 4.11

  • gary 385 posts 916 karma points
    Jan 22, 2013 @ 09:36
    gary
    0

    Hi Rob

    From your example, I take it you are using webforms razor?

    Ok, this is for MVC Razor, but the logic should remain true, you will need to adapt it slightly;

    @{     

        var root = CurrentPage.AncestorOrSelf();

        var nodes = root.Descendants().Where("Visible");

        }    

    <ul>

        @{

        foreach (var d in nodes)

       { 

           <li>(@d.Level) @d.Name</li>

    }

    }

        </ul>

    The difference should be the "getting" of the root, ie establish this as an entity first. This returns true down to level 4 on my current development.

    For a simple breadcrumb navigation, @CurrentPage.Up().NiceUrl()  gives the desired links, but again this is in MVC Razor so will need to be adapted for Webforms.

    Hope this helps, sorry not in Webforms, but it just shows how flexible Umbraco is, use what you prefer, fantastic!
    Regards
    G
  • Rob 5 posts 55 karma points
    Jan 22, 2013 @ 09:47
    Rob
    100

    @gary, i'm sorry but the problem is not building the breadcrumb. 

    I now know that it probably is a bug in umbraco. (See this issue)

    But i don't think there is a fix for v4 yet. :(

  • gary 385 posts 916 karma points
    Jan 22, 2013 @ 10:09
    gary
    0

    Hi Rob,

    Apologies if I misunderstood - 

    Ok, just moved a node up the tree, republished entire site and yes, the level remained as it was before in both V6 and V4.11.1

    então, concordamos.

    G

Please Sign in or register to post replies

Write your reply to:

Draft