mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:43:35 +08:00
#16797: Adding setting for global paging. Fixing issue with query string specified pagesize being the same as default size.
--HG-- branch : dev
This commit is contained in:
@@ -11,20 +11,29 @@ using Orchard.Themes;
|
||||
using Orchard.UI.Navigation;
|
||||
|
||||
namespace Orchard.Core.Containers.Controllers {
|
||||
using Orchard.Settings;
|
||||
|
||||
public class ItemController : Controller {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IContainersPathConstraint _containersPathConstraint;
|
||||
private readonly ISiteService _siteService;
|
||||
|
||||
public ItemController(
|
||||
IContentManager contentManager,
|
||||
IContainersPathConstraint containersPathConstraint,
|
||||
IShapeFactory shapeFactory,
|
||||
ISiteService siteService) {
|
||||
|
||||
public ItemController(IContentManager contentManager, IContainersPathConstraint containersPathConstraint, IShapeFactory shapeFactory) {
|
||||
_contentManager = contentManager;
|
||||
_containersPathConstraint = containersPathConstraint;
|
||||
_siteService = siteService;
|
||||
Shape = shapeFactory;
|
||||
}
|
||||
|
||||
dynamic Shape { get; set; }
|
||||
|
||||
[Themed]
|
||||
public ActionResult Display(string path, Pager pager) {
|
||||
public ActionResult Display(string path, PagerParameters pagerParameters) {
|
||||
var matchedPath = _containersPathConstraint.FindPath(path);
|
||||
if (string.IsNullOrEmpty(matchedPath)) {
|
||||
throw new ApplicationException("404 - should not have passed path constraint");
|
||||
@@ -51,7 +60,8 @@ namespace Orchard.Core.Containers.Controllers {
|
||||
var descendingOrder = container.As<ContainerPart>().Record.OrderByDirection == (int) OrderByDirection.Descending;
|
||||
query = query.OrderBy(container.As<ContainerPart>().Record.OrderByProperty, descendingOrder);
|
||||
|
||||
pager.PageSize = pager.PageSize != Pager.PageSizeDefault && container.As<ContainerPart>().Record.Paginated
|
||||
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
|
||||
pager.PageSize = pagerParameters.PageSize != null && container.As<ContainerPart>().Record.Paginated
|
||||
? pager.PageSize
|
||||
: container.As<ContainerPart>().Record.PageSize;
|
||||
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
|
||||
|
Reference in New Issue
Block a user