Difference between revisions of "Block layout"

Jump to: navigation, search
m (Resetting the block layout for existing courses: Added script warning)
Line 44: Line 44:

Revision as of 04:37, 16 May 2009

Default block layout for new courses

Sticky blocks may be used in Moodle 1.6.

Alternatively, to amend the default block layout for new courses (in all versions of Moodle), add one or more of the following lines (omitting the forward slashes) to config.php and amend the block names as required.

Note how the colon is used to separate those blocks appearing on the left, from those appearing on the right.

// These variables define DEFAULT block variables for new courses
// If this one is set it overrides all others and is the only one used.
//      $CFG->defaultblocks_override =    'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';
// These variables define the specific settings for defined course formats.
// They override any settings defined in the formats own config file.
//      $CFG->defaultblocks_site = 'site_main_menu,admin,course_list:course_summary,calendar_month';
//      $CFG->defaultblocks_social =  'participants,search_forums,calendar_month,calendar_upcoming,social_activities,recent_activity,admin,course_list';
//      $CFG->defaultblocks_topics =  'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';
//      $CFG->defaultblocks_weeks =  'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';
// These blocks are used when no other default setting is found.
//      $CFG->defaultblocks = 'participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity';</pre>

(code copied from config-dist.php)

Resetting the block layout for existing courses

The block layout for existing courses may be reset by copying the following script into a text file, saving it as resetblocks.php, copying it into the Moodle root directory, then visiting

Warning: This script may change the layout of your course pages and also remove blocks from those pages if they have not been specified in the config.php line. Check which of your courses has blocks which are not in the config.pho line and be prepared to spend time adding blocks to your course pages again. Please note that a database backup is recommended before using the script.

$courses = get_records('course');
foreach($courses as $course) {
   $page = page_create_object(PAGE_COURSE_VIEW, $course->id);

See also

Using Moodle Default Block Layout for moodle 1.9 forum discussion