c a n d l a n d . n e t

N2cms Navigation Options on a MVC Site

Dusty Candland | |

Add the n2 SlidingCurtain control with a DragDropControlPanel control inside it after the opening body tag. This will link to the editing system of n2cms.

<n2:SlidingCurtain ID="SlidingCurtain1" runat="server">
    <n2:DragDropControlPanel ID="DragDropControlPanel1" runat="server" />
</n2:SlidingCurtain>

Now there are a bunch of N2 functions that can be used to interface with the navigation system.

To setup the menu the following can be used, the first list item shows a link to the home page. The second list item shows the sub pages.

<ul id="menu">
    <li><a href="<%= N2.Find.StartPage.Url %>">Home</a></li>
    <%= N2.Web.Tree.From(N2.Find.StartPage, 2).Filters(new N2.Collections.NavigationFilter()).ExcludeRoot(true)%>
</ul>

Next to setup the sub navigation something like this could be used.

<div class="leftColumn" style="border:solid 1px black">
    <h2><%= N2.Utility.Evaluate(N2.Find.AtLevel(N2.Find.CurrentPage, N2.Find.StartPage, 2), "Title") %></h2>
    <ul>
        <%= N2.Web.Tree.Between(N2.Find.CurrentPage, N2.Find.StartPage, true, 2).Filters(new N2.Collections.NavigationFilter()).ExcludeRoot(true) %>
    </ul>
</div>

Bread crumbs can be setup using.

<% foreach(N2.ContentItem item in N2.Find.EnumerateBetween(N2.Find.StartPage, N2.Find.CurrentPage, false)) { %>
    <%= N2.Web.Link.To(item) %> /
<% } %>
<%= N2.Utility.Evaluate(N2.Find.CurrentPage, "Title") %>

Lastly, you can update the page title using something similar to what’s been used above.

<title><%= N2.Utility.Evaluate(N2.Find.CurrentPage, "Title") %><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: