I'm trying to make my content CMS more user friendly by listing content in the following fashion:
Parent - Sub Page - - Sub Page - - - Sub Page - - - - etc...
Using .NET/MVC2, where would this function be defined and how would it be called.
This is my page listing my content:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Content.master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Head" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<ul>
<%
foreach (var item in Model) {
string contentTitle = item.Title;
%>
<li class="row"><%: Html.ActionLink(contentTitle, "contentedit", new { id = item.ID }) %></li>
<!-- List subpages recursively -->
<% } %>
</ul>
</asp:Content>
This is my Action in my Controller:
public ActionResult Content()
{
// Get just parent items -- for now.
List<SiteContent> viewData = DB.SiteContents.Where(c => c.ParentID == null).OrderBy(c => c.ParentID).ToList();
return View(viewData);
}