Admin Content browser "Show: All" displays pager


And obviously, the pager does nothing

file attachments


sebastienros wrote Feb 18 at 8:36 PM

todo: remove the page links and prev/next but display only the DDL with page count

CraigLittlewood wrote Nov 26 at 12:39 PM

I have the same problem.

jtkech wrote Dec 3 at 1:39 AM

@jchenga you're right but I have seen others drawbacks and inconsistencies

The site.PageSize setting = 0, go to content list, select the ALL option, it fails
A zero size option has been added and selected, the ALL option is also selected but with no link data

In Pager.cshtml, replace (line 36 in 1.8.x)
    if (!pageSizes.Contains(defaultPageSize)) {
    if (defaultPageSize > 0 && !pageSizes.Contains(defaultPageSize)) {
Select a low size option, go to the last page, select a much higher size, the pager is inconsistent
It displays too many page links, with some text like: Showing items 431 - 15 of 15

We need to adapt the page number of the size ActionLink to retrieve the 1st item of the current page
In Pager.cshtml, after currently line 49, we can add these variable initializations
  var pageId = String.IsNullOrEmpty(Model.PagerId) ? "page" : Model.PagerId;
  var nPage = Math.Max(1, Convert.ToInt32(routeData[pageId]));
  var firstItem = ((nPage - 1) * Model.PageSize) + 1;
Before the ALL option action link, currently line 54 in 1.8.x, add
  routeData[pageId] = 1;
And before the size option action link in the foreach loop, currently line 63, add
  routeData[pageId] = size > 0 ? Math.Ceiling((double)firstItem / size) : 1;
If only one page, to completely remove page links (even page 1), only display the items count

In CoreShape.cs, , currently line 519, replace
 if (numberOfPagesToShow > 0) {
  if (numberOfPagesToShow > 0 && lastPage > 1) {
To be more consistent, prevent totalPageCount to have an infinite negative value

In Pager.cshtml, currently line 20, replace
  var totalPageCount = (int)Math.Ceiling((double)Model.TotalItemCount / Model.PageSize);
  var totalPageCount = Model.PageSize > 0 ? (int)Math.Ceiling((double)Model.TotalItemCount / Model.PageSize) : 1;
Same logic in CoreShape.cs, currently line 446, replace
  var totalPageCount = (int)Math.Ceiling(TotalItemCount / pageSize);
  var totalPageCount = pageSize > 0 ? (int)Math.Ceiling(TotalItemCount / pageSize) : 1;
With the previous replacement, in CoreShape.cs we no longer need to test the pageSize line 439

We can comment or remove these 2 lines, line 439 and 440
  // if (pageSize < 1)
  //   pageSize = _workContext.Value.CurrentSite.PageSize;
Finally, with the ALL option, do we have to consider the site.MaxPageSize setting (not the site.PageSize) ?
If so, we need others update as in the pager constructor, but here it depends what is by design

Thank you

jchenga wrote Tue at 5:12 AM

@jtkech Thanks for the suggestions. I have created another PR request incorporating your codes: https://orchard.codeplex.com/SourceControl/network/forks/jchenga/orchardfork/contribution/7824