Copied to clipboard

Flag this post as spam?

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


  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 01, 2014 @ 13:57
    Jeppe Ladefoged
    0

    Partial output from navigation

    Hi

    I've been trying to get my head around why my navigation macro isn't outputting the pages the currently have in the site root. I get not errors and i'm using the standard navigation snippet supplied with Umbraco 6.2.2.

    Problem is i'm seeing the <nav> and <ul> but no <li>'s within in frontend. URL: http://nssas.dk.nt7.unoeuro-server.com/

    I have tried changing the "root" variable to "AncestorOrSelf("Forside");" which is "Home" but that doesn't do a darn thing.

    Any help will be appreciated. Thanks a lot in advance.

    Navigation Razor snippet:

    @{ 

    @* Get the root of the website *@

        var root = Model.AncestorOrSelf(1);

    }

    <nav class="main-navigation">

    <ul class="nav navbar-nav navbar-right">

        @foreach (var page in root.Children.Where("Visible"))

        { 

            <li class="@page.IsAncestorOrSelf(Model, "current", "")">

                <a href="@page.Url">@page.Name</a>

            </li>

    }

    </ul>

    </nav> 

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 01, 2014 @ 14:08
    Dennis Aaen
    0

    Hi Jeppe, and welcome our.

    When you say partial did you mean a partial view or parital view marco, if so try this code instead.

    @{ 
        @* Get the root of the website *@

        var root = CurrentPage.AncestorOrSelf(1);

        <nav class="main-navigation">

            <ul class="nav navbar-nav navbar-right">
                @foreach (var page in root.Children.Where("Visible")){
                    <li class="@page.IsAncestorOrSelf(CurrentPage, "current", "")">
                        <a href="@page.Url">@page.Name</a>
                    </li>

                }
            </ul>
        </nav>
    }

    Hope this helps,

    /Dennis

  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 01, 2014 @ 14:26
    Jeppe Ladefoged
    0

    Hi Dennis

    Thanks you for the welcome and your suggestion. Unfortunatly your code outputs the same as mine. Meaning and empty <ul> with no <li>'s (no pages) from navigation script except what you see in my screenshot i my first post above.

    I seems the PV Razor Macro is working fine but for some reason does not output the pages in the navigation...

    Thanks again and sorry for the confusion regardinga "partial view" or "parital view macro".

  • Jeppe Ladefoged 15 posts 65 karma points
    Oct 01, 2014 @ 15:56
    Jeppe Ladefoged
    100

    Ok, i redid my page-structure and that fixed the problem :) Thanks again

Please Sign in or register to post replies

Write your reply to:

Draft