Search This Blog

Wednesday, April 25, 2012

Create an empty page for Moodle

I came across this code in the forum today and I thought it's a nice snippet to keep. This shows how to create a new, blank page within the moodle system.


<?php


// The number of lines in front of config file determine the // hierarchy of files.
require_once(dirname(dirname(__FILE__)).'/../config.php');


$PAGE->set_context(get_system_context());
$PAGE->set_pagelayout('admin');
$PAGE->set_title("Your title");
$PAGE->set_heading("Blank page");
$PAGE->set_url($CFG->wwwroot.'/blank_page.php');


echo $OUTPUT->header();


// Actual content goes here
echo "Hello World";


echo $OUTPUT->footer();
?>

Simple as that!

1 comment:

  1. Thanks for the tip. Exactly what I was looking for.

    As for Moodle 3, get_system_context() has been deprecated. Instead do: $PAGE->set_context(context_system::instance());

    ReplyDelete