From 768b4ecc2c5137f221185d8a8942f08cec7a5af6 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 23 Feb 2012 18:53:25 -0800 Subject: [PATCH] Fixing blogs paging --HG-- branch : 1.x --- .../Controllers/BlogController.cs | 12 +++++++--- .../Orchard.Blogs/Handlers/BlogPartHandler.cs | 2 +- .../Modules/Orchard.Blogs/Routes.cs | 22 ++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs index 5d383ed15..088afe2c6 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Controllers/BlogController.cs @@ -58,13 +58,19 @@ namespace Orchard.Blogs.Controllers { return View((object)viewModel); } - public ActionResult Item(int blogId, PagerParameters pagerParameters) { + public ActionResult Item(string blogPath, PagerParameters pagerParameters) { Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters); - var blogPart = _blogService.Get(blogId, VersionOptions.Published).As(); - if (blogPart == null) + var correctedPath = _blogPathConstraint.FindPath(blogPath); + if (correctedPath == null) return HttpNotFound(); + var blogPart = _blogService.Get(correctedPath); + + //var blogPart = _blogService.Get(blogId, VersionOptions.Published).As(); + //if (blogPart == null) + // return HttpNotFound(); + _feedManager.Register(blogPart); var blogPosts = _blogPostService.Get(blogPart, pager.GetStartIndex(), pager.PageSize) .Select(b => _services.ContentManager.BuildDisplay(b, "Summary")); diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs index 1f19d71cb..02c597776 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Handlers/BlogPartHandler.cs @@ -35,7 +35,7 @@ namespace Orchard.Blogs.Handlers { {"Area", "Orchard.Blogs"}, {"Controller", "Blog"}, {"Action", "Item"}, - {"blogId", context.ContentItem.Id} + {"blogPath", context.ContentItem.As().Path} }; context.Metadata.CreateRouteValues = new RouteValueDictionary { {"Area", "Orchard.Blogs"}, diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Routes.cs b/src/Orchard.Web/Modules/Orchard.Blogs/Routes.cs index 3883676a3..2cc854004 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Routes.cs +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Routes.cs @@ -6,12 +6,15 @@ using Orchard.Mvc.Routes; namespace Orchard.Blogs { public class Routes : IRouteProvider { + private readonly IBlogPathConstraint _blogPathConstraint; private readonly IArchiveConstraint _archiveConstraint; private readonly IRsdConstraint _rsdConstraint; public Routes( + IBlogPathConstraint blogPathConstraint, IArchiveConstraint archiveConstraint, IRsdConstraint rsdConstraint) { + _blogPathConstraint = blogPathConstraint; _archiveConstraint = archiveConstraint; _rsdConstraint = rsdConstraint; } @@ -177,7 +180,24 @@ namespace Orchard.Blogs { }, new MvcRouteHandler()) }, - new RouteDescriptor { + new RouteDescriptor { + Priority = 11, + Route = new Route( + "{*blogPath}", + new RouteValueDictionary { + {"area", "Orchard.Blogs"}, + {"controller", "Blog"}, + {"action", "Item"}, + }, + new RouteValueDictionary { + {"blogPath", _blogPathConstraint} + }, + new RouteValueDictionary { + {"area", "Orchard.Blogs"} + }, + new MvcRouteHandler()) + }, + new RouteDescriptor { Route = new Route( "{*path}", new RouteValueDictionary {