This project is read-only.

Projection's - Conditionally show the pager

Topics: Core, Customizing Orchard
Mar 27, 2012 at 4:26 PM

I am using a series of projects which work out fantastic. Super feature. When I include the option for paging the results page still shows the pager even though there is nothing to page. I have a solution which is to override the view template in my theme [Parts.ProjectionPart-ProjectionPage.cshtml] and add an additional guard to the display call for the pager.

@if ((bool)Model.ContentPart.Record.DisplayPager && (int)Model.ContentPart.Record.Items > 0)

Is there a better approach to solving this problem? Did I miss a configuration setting? Would this make sense to push as a patch to the core projection pager logic? Seems like you only want to display a pager when there is data that warrants it.

Mar 27, 2012 at 8:05 PM

Well, a better approach would be to keep pager concerns in a pager template override. Please feel free to file a bug for this, I think this should be the default behavior.

Mar 28, 2012 at 5:52 PM

Bertrand can you elaborate on the pager template override? I see where I can fix the issue in Orchard.Core/Coreshapes.cs

Line 470 changes from

            // page numbers
            if (numberOfPagesToShow > 0)

            // page numbers
            if (numberOfPagesToShow > 0 && firstPage != lastPage)

I will open a bug but I would still like to understand the recommended injection point for a fix. I am not sure what you meant by pager template override. 


Mar 31, 2012 at 12:28 AM

I'll write a short post.

Mar 31, 2012 at 5:53 AM

OK, it's posted:

Mar 22, 2013 at 9:45 PM
How can I keep TheAdmin Pager-shape working through ajax-scripting when calling controller action w/o [Admin] attribute?

I have page showing list of rows from db and I have filtering field which calls controller's action via ajax. When I filter results, pager switches to basic pager and TheAdmin Pager.cshtml is not run. I understand that this is by design, but what steps I would need to do in order to mimic normal TheAdmin style pager ?