Changing topic or weekly outline to Page heading

Jump to: navigation, search
Warning: This page is no longer in use. The information contained on the page should NOT be seen as relevant or reliable.

This document describes how you make a course page display the course name instead of 'Topic outline' or 'Weekly outline', in three easy moves.

Getting started

To do this tutorial you will need direct access to your theme files. When told to OPEN a file use Notepad or a Text editor of your choice. I use TextPad [1]

Course page layout

First you will need to make a copy of your theme's layout/general.php and save it as layout/course.php, this is so that you can add some code that only gets triggered in a course page setting.

Add code to course.php

This is the code we are going to add.

<h2 class="headingblock"><?php echo $PAGE->heading;?></h2>

It's a simple bit of HTML and a line of PHP nothing fancy. It tells Moodle that you want to add a header just before the Main Content is loaded to the page. Because we are specifying a certain point in the page we can be certain the header will appear just where we want it to.

You need to open course.php and ADD the above code just before <?php echo $OUTPUT->main_content() ?> (in Moodle 2.2.x) or <?php core_renderers MAIN_CONTENT_TOKEN ?> (in Moodle 2.1.x and Moodle 2.0.x).

so that it looks like this...

<h2 class="headingblock"><?php echo $PAGE->heading;?></h2>
<?php echo core_renderer::MAIN_CONTENT_TOKEN ?>

if you are using Moodle 2.0.x or 2.1.x or this...

<h2 class="headingblock"><?php echo $PAGE->heading;?></h2>
<?php echo $OUTPUT->main_content() ?>

if you are using Moodle 2.2.x

Don't forget to save your changes!

CSS Rulz

Next we need to tell Moodle that we no longer want to see 'Topic outline' or 'Weekly outline' now that we have our new header in place.

Create and add a CSS rule

Open your theme's style/core.css file and add the following CSS rule.

h2.headingblock.outline {display:none;}

Configuration

Now that we have our course.php layout file with our new header added in it. We need to tell Moodle that we want to use this new layout file rather than the current one. So we need to makes some changes to the theme's config.php.

Change $THEME->layouts in config.php

Finally open your theme's config.php and change the $THEME->layouts for 'course' and 'incourse' from 'general.php' to 'course.php' like this...

// Main course page
    'course' => array(
        'file' => 'course.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-post',
        'options' => array('langmenu'=>true),
    ),
 
and this...
 
    // part of course, typical for modules -
    // default page layout if $cm specified in require_login()
    'incourse' => array(
        'file' => 'course.php',
        'regions' => array('side-pre', 'side-post'),
        'defaultregion' => 'side-pre',
    ),

And that's it!

Happy Moodling :)