Copied to clipboard

Flag this post as spam?

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


  • Robert Hamm 7 posts 27 karma points
    Feb 28, 2013 @ 06:04
    Robert Hamm
    0

    cshtml main menu navigation problem.

    Hi all. I am having a problem with my main menu navigation code.

    The navigation builds fine but whenever you switch to a particular sub page that sections menu no longer is rendered.

    The menu CSHTML is on the master template and here is the code. The website to view yourself is http://seal-krete.habanero.com.

     

       <umbraco:Macro  runat="server" language="cshtml">
    
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{ 
        var level = String.IsNullOrEmpty(Parameter.Level) ? 1 : int.Parse(Parameter.Level); 
        var parent = @Model.AncestorOrSelf(level);
        if (parent != null) {
            <ul id="nav">
            @foreach (var item in parent.Children.Where("Visible")) {
                var selected = Array.IndexOf(Model.Path.Split(','), item.Id.ToString()) >= 0 ? " class=\"selected\"" : "";
                <[email protected](selected) class="parentOfDropDown">
                    <a href="@item.Url">@item.Name</a>
                        @if (item.Children != null)
                        {
    
                            <ul class="dropDown">
                                @foreach (var sub in item.Children) {
                                    <li>
                                        <a href="@sub.Url">@sub.Name</a>
                                        <ul>
                                            @foreach (var subItem in sub.Children) {
                                                <li>
                                                    <a href="@subItem.Url">@subItem.Name</a>
                                                </li>
                                            }
                                        </ul>
                                    </li>
                            }
                            </ul>
                        }
    
                </li>
    
                }
            </ul>
            }
    
    }
    
    </umbraco:Macro>
    
  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 28, 2013 @ 12:19
    Jeroen Breuer
    0

    Seems to work on the website. Might be good to read this topic about menu's in Razor: http://our.umbraco.org/forum/developers/razor/28479-Razor-menu-performance-(v4)

    Jeroen

  • Robert Hamm 7 posts 27 karma points
    Feb 28, 2013 @ 15:39
    Robert Hamm
    0

    Yes this navigation works when on the home page but if you click on one of the subpages IE: Garage Floors, then try to hover over garage floors again when inside the page the drop down no longer is there.

     

  • Robert Hamm 7 posts 27 karma points
    Feb 28, 2013 @ 15:43
    Robert Hamm
    0

    Wow.. I am dumb. Sorry.

    When I added the class selected to the drop down link the CSS I was using to show the drop down broke.

    Stupid thread is stupid. haha.. Well if anything someone can use the above code to create a drop down :)

Please Sign in or register to post replies

Write your reply to:

Draft