0

Could you provide me step by step how to create Bootstrap 3 Menu Navigation Bar and Breadcrumb using MVCSiteMap MVC5?

I've got problem when change this code to Bootstrap model

@model MvcSiteMapProvider.Web.Html.Models.MenuHelperModel
@using System.Web.Mvc.Html
@using MvcSiteMapProvider.Web.Html.Models

<ul id="menu" class="nav navbar-nav">
    @foreach (var node in Model.Nodes)
    {
        <li>
            @Html.DisplayFor(m => node)
        @if (node.Children.Any())
        {
            @Html.DisplayFor(m => node.Children)
        }
    </li>
    }
</ul>

what I want is, there is BootstrapMenuHelperModel that read mvcSiteMapNode transform into navigation menu.

1
  • 1
    You should have a go at it and come back with specific issues that we may be able to help with if you find you are having trouble.
    – user61470
    Apr 17, 2014 at 7:36

2 Answers 2

1

You are likely having issues because you have only solved part of the CSS problem. There are 3 different templates that are used by the Menu and 2 of them are also used by other HTML helpers. For that reason, it might be a good idea to create named templates (as in the example answer below) to create separate templates for each HTML helper (Menu, SiteMapPath, SiteMap, etc). For each level of nodes, the Menu recursively calls the SiteMapNodeListHelper, which might not be producing the HTML that Bootstrap is expecting (depending on which of the nav options you are using).

See this answer for a starting point, and then you can modify the HTML and class attributes from there.

Keep in mind you can also use custom attributes to supply additional data (such as CSS class names) based on the node selected, or you can use the IsCurrentNode and IsInCurrentPath properties of the SiteMapNodeModel to determine if the current node is active, if needed.

0
0

Here is a tutorial how to style your Sitemap:

Tutorial

Install Bootstrap and apply the classes to the tutorial:

Nav Bootstrap

1
  • this is just styling mvcsitemap with css, see my edited question
    – Willy
    Apr 17, 2014 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.