Page layouts

Inside a theme directory, there may be a layouts directory with a number of PHP files. These files how a particular page layout is displayed.

Defining

Within the theme's config.php, there can be a $THEME→layouts array which can define the details for an individual page layout.

The key for the layout is the name of the layout (eg. 'incourse') and the value is another array with the keys:

  • file: This is required and points to the file in the layouts directory - the file that can be used be in a child or parent theme (depending on the theme in use)
  • regions: This is required and is an array of strings containing the names of the regions that this layout supports - when naming regions, try to name them for what they are and not where they are positioned eg. use "side-pre" instead of "left" as for Right to Left Languages (such as Hebrew and Arabic) "left" is likely to be on the right side
  • defaultregion: This is an optional string stating where blocks are to be added by default
  • options: This is an optional array of key => value pairs of variables that is passed into the layout file (they can be accessed through the $PAGE→layout_options array) - this allows one layout file to be used in different manors for different page layouts

Core page layouts

KeyDescription
base

Most backwards compatible layout without the blocks. This is the layout used by default

standardUsed for pages with general information.
noblocks

Pages that need to use the full width where no blocks should be shown at all.

courseThe main course page.
coursecategory

The old course catalogue (not the enhanced version).

incourseUsed when inside a course module. Default page layout if $cm specified when calling require_login.
frontpageThe site home page.
adminServer administration pages.
mydashboard

User related pages. 

This does not refer to Dashboards.

dashboardDashboard page layout.
mypublic

User profile pages.

login

The log in page.

popup

Pages that are displayed in a pop up window.

frametopUsed with legacy frame layouts only.
embedded

Pages that are embedded in others (e.g. iframes / object).

maintenance

Used when the site is undergoing maintenance / installation. Should not expect the database to be available.

print

Used when viewing pages optimised for printing.

redirectUsed when the user is being redirected.
report

Used when viewing reports (including some reportbuilder reports).

secure

Used when viewing using safebrowser and securewindow when doing quizzes.

There may be other layouts that have been added by non-core functionality. If any of these are not defined, they will fall back to the base layout.

Writing a page layout file

A page layout file contains the HTML that surrounds the content on the page. It should contain the HTML doctype, header information along with a call to:

$OUTPUT->main_content