{{ :format:page:logo-apl.png?nolink |}} ===== Page format: Technical guide ===== ==== Capabilities ==== * [[:format:page:capabilities|Page format capabilities guide]] ==== Event listeners ==== * Module creation: reorders and consolidates the section plan * Module deletion: reorders and consolidates the section plan * Course deletion: cleans the page format's additional tables ==== 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: * Either concern the theme, which is one of the places traditionally customised in Moodle * Or concern customscripts replacing some standard Moodle entry points. ==== 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: * Creating a //customscripts// directory at the root of the Moodle installation. * Editing the config.php file to enable customscripts ($CFG->customscripts = >/customscripts) * copying the contents of the _customscripts directory into the above-mentioned directory ---- ==== 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: * /course/format/page/cl/redraw_all_sections.php Recomputes the integrity of the course sections (standard Moodle) against their matching pages in the page format. For a given course cd /course/format/page/cli sudo -u php redraw_all_sections.php --courses= (*) 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. ---- [[format:page|Back to the Page Format component index]] - [[:Plugins|Back to plugins index]] - [[:start|Back to catalogue]]