Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38260

Enhance render_paging_bar renderer

    XMLWordPrintable

    Details

      Description

      edit: this is an old bug, but I've just moved it to Mobile devices issues. As well as fixing some bugs and generally making the pagination bar look a bit nicer and making the HTML easier to theme, a primary impact of this change is to make the pagination links more finger friendly on touch based devices.

      While working on a theme I found that the existing paging bar used in Moodle had various issues, detailed here:

      https://tracker.moodle.org/browse/MDL-35367

      I wrote a renderer (and some supporting code) to fix this, and I'll like to integrate the changes back into core Moodle.

      Just to be clear, I'm more interested in getting it fixed than in my code being used. If you want to treat the following as a very specific and detailed bug report then feel free.

      On the other hand, as long as someone can point me in the right direction on how to do this "the Moodle way" I'm happy to entirely rewrite the code to fit in with the core code guidelines.

      I'm not sure which of the above choices is appropriate so for the time being I'll link to the code I wrote in a theme renderer. I went out of my way to avoid touching core code, some of which has bugs I needed to work around, basically reimplementing paging_bar within my theme so someone needs to re-write this before it can be included in core.

      So the actual renderer code is here:

      https://github.com/ds125v/moodle-theme_bootstrap_renderers/blob/master/renderers/core_renderer.php#L532-L546

      The code that decides which pages to link to (and which to leave out if space is tight) is here:

      https://github.com/ds125v/moodle-theme_bootstrap_renderers/blob/master/renderers/pager.php

      And the code that takes that list of page numbers and turns it into a series of HTML list items with appropriate classnames and containing links is here:

      https://github.com/ds125v/moodle-theme_bootstrap_renderers/blob/master/renderers/bootstrap_pager.php

      And, just for completeness the bit that wraps those in an appropriately classed ul tag is here:

      https://github.com/ds125v/moodle-theme_bootstrap_renderers/blob/master/renderers/bootstrap.php#L124-L126

      There's unit tests for all of that too.

      I notice that there's some other bugs against paging_bar with work ongoing at the moment, I'll mark them as related to this. I also noticed that mod_glossary has it's own implementation of this idea, with an added ALL button, so there should probably be some harmonisation done there.

        Attachments

        1. after.png
          after.png
          147 kB
        2. before.png
          before.png
          142 kB

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                bawjaws David Scotson
                Participants:
                Component watchers:
                Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Bas Brands, Barbara Ramiro, Jake Dallimore, Jun Pataleta
              • Votes:
                2 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: