diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs index 894271846..15be6713b 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -7,6 +7,8 @@ using System.Web.Routing; using Orchard.ContentManagement; using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.MetaData; +using Orchard.ContentManagement.Records; +using Orchard.Core.Common.Models; using Orchard.Core.Contents.ViewModels; using Orchard.Data; using Orchard.Localization; @@ -43,6 +45,9 @@ namespace Orchard.Core.Contents.Controllers { public ILogger Logger { get; set; } public ActionResult List(ListContentsViewModel model) { + if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null) + return new NotFoundResult(); + const int pageSize = 20; var skip = (Math.Max(model.Page ?? 0, 1) - 1) * pageSize; @@ -59,6 +64,9 @@ namespace Orchard.Core.Contents.Controllers { query = query.ForType(model.TypeName); } + if (model.ContainerId != null) + query = query.Join().Where(cr => cr.Container.Id == model.ContainerId); + var contentItems = query.Slice(skip, pageSize); model.Entries = contentItems.Select(BuildEntry).ToList(); diff --git a/src/Orchard.Web/Core/Contents/Routes.cs b/src/Orchard.Web/Core/Contents/Routes.cs new file mode 100644 index 000000000..09ec9a84f --- /dev/null +++ b/src/Orchard.Web/Core/Contents/Routes.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using System.Web.Mvc; +using System.Web.Routing; +using Orchard.Mvc.Routes; + +namespace Orchard.Core.Contents { + public class Routes : IRouteProvider { + #region IRouteProvider Members + + public void GetRoutes(ICollection routes) { + foreach (RouteDescriptor routeDescriptor in GetRoutes()) { + routes.Add(routeDescriptor); + } + } + + public IEnumerable GetRoutes() { + return new[] { + new RouteDescriptor { + Priority = 5, + Route = new Route( + "Admin/Contents/List/{id}/InContainer/{containerId}", + new RouteValueDictionary { + {"area", "Contents"}, + {"controller", "Admin"}, + {"action", "List"} + }, + new RouteValueDictionary(), + new RouteValueDictionary { + {"area", "Contents"} + }, + new MvcRouteHandler()) + } + }; + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs b/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs index 450219e07..90d108797 100644 --- a/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs +++ b/src/Orchard.Web/Core/Contents/ViewModels/ListContentsViewModel.cs @@ -9,6 +9,7 @@ namespace Orchard.Core.Contents.ViewModels { } public string Id { get; set; } + public int? ContainerId { get; set; } public string TypeName { get { return Id; } diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 3270c9c09..fe6af3d63 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -78,6 +78,7 @@ + diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx index 3d3e3c0d0..83b8bc199 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Views/DisplayTemplates/Parts/Blogs.BlogPost.List.ascx @@ -2,4 +2,4 @@ <%@ Import Namespace="Orchard.Mvc.ViewModels"%> <%@ Import Namespace="Orchard.Blogs.Models"%> <%: Html.UnorderedList(Model, (bp, i) => Html.DisplayForItem(bp), "blogPosts contentItems") %> -<% if (Model.Count() < 1) { %>
<%: T("There are no posts for this blog.") %>
<% } %> +<% if (Model.Count() < 1) { %>
<%: T("There are no posts for this blog.") %>
<% } %> \ No newline at end of file