Table des matières

Page format: Technical guide

Capabilities

Event listeners

Additional notes on implementation

The page format is a very powerful format that requires a bit of integration know-how.

Since its original version for Moodle 2.3, a big effort has been made to get rid of as many patches in the Moodle core as possible. This architectural work is now complete. The page format, for normal operation, must nevertheless be preceded by a rigorous setup of some superficial overrides of Moodle's standard behaviour. All of these overrides:

Essential setups

Replacing the course view

Moodle provides for the block manager to be based on a “Factory” design pattern. This pattern avoids the invoked class being set in stone at runtime. It can be changed with a minimum of code modifications.

Unfortunately, a small architectural flaw does not allow defining the block manager by simple configuration when entering a course. This choice is made at the start of the course view, code that is part of the core. Fortunately, since this script is a Moodle “entry point”, it can easily be diverted.

The page format distribution offers, in a __customscripts directory, a set of workarounds for the current Moodle version. Setting up is simple and consists of:


Optional setups

These setups do not prevent the page format from working correctly, but can add greater navigation consistency in some use cases.

Paginated navigation in page overrides by activities

When a page is entirely overridden by an activity, the course reading sequence is stopped on the activity to play it through its different screens. The display context leaves the course and goes into that of the activity, which most often unfolds with “standard” Moodle layouts (and therefore without taking this particular situation into account). Some activities published by Edunao already natively support integration with the page format, by invoking this format's navigation at the bottom of the screen.

For the others that do not provide for it, some workarounds through customscripts must be added, in order to inject this navigation at the bottom of the page.

:!: WARNING, not all activities are architected to allow an easy workaround. The most suitable are those that make an explicit call to:

  echo $OUTPUT->footer();

In the view to override (an entry view always starts with the call to “config.php”).

At that point, you can copy this view into an isomorphic directory in the customscripts, and add, just before the call to footer, the following page format navigation sequence:

 if ($course->format == 'page'){
     require_once $CFG->dirroot.'/course/format/page/xlib.php';
     page_print_page_format_navigation($cm, true);
 }

As for all overrides by customscript, do not forget to end your page with

 die;

After calling the footer, to avoid replaying the original view.

Page structure repair procedures

It can still happen, in some cases of complex manipulations, that the page format structure is disturbed or altered, causing lost modules, badly indexed in pages and sections. The following scripts allow running corrective procedures, general or targeted:

For a given course <IDC>

 cd <moodleroot>/course/format/page/cli
 sudo -u<webuser> php redraw_all_sections.php --courses=<IDC>

(*) A comma-separated list of ids can be given to the command. Without the –courses parameter, the correction runs on the whole platform, for all detected page format courses. It is advised to back up the database before a global correction operation. (**) Note that badly attached modules are recovered and reattached in the sections/pages, unlike the correction tools through the page format audit interface in web mode. The latter clean the data by destroying the additional unattached elements.


Back to the Page Format component index - Back to plugins index - Back to catalogue