Reputation: 1209
I have a Moodle site with custom regions, namely 'top' and 'bottom'. I would like to automatically add an HTML block to all new courses in the top region.
I have these in my config.php
, and the block is added to the new courses, but in the wrong place, to side-pre
region... How can I change this to add the block to the top region?
'course' => array(
'file' => 'course.php',
'regions' => array('side-pre', 'top', 'bottom'),
'defaultregion' => 'bottom',
'options' => array('nonavbar'=>false),
$CFG->defaultblocks_override = 'html';
$CFG->defaultblocks_site = 'html';
$CFG->defaultblocks_social = 'html';
$CFG->defaultblocks_topics = 'html';
$CFG->defaultblocks_weeks = 'html';
Upvotes: 1
Views: 3231
Reputation: 5943
Citing from the docs (Default block layout for new courses):
$CFG->defaultblocks_topics = 'participants,tags,admin:messages,online_users,recent_activity';
Note how the colon is used to separate those blocks appearing on the left, from those appearing on the right.
It seems like you would have to use a colon. I looked at the function code, that parses this string (in lib/blocklib.php
, function blocks_parse_default_blocks_list
, Moodle 2.4) and I think it could only handle left or right regions (side-pre
and side-post
). For an hackish solution, you could change this lines of code (in lib/blocklib.php
):
define('BLOCK_POS_LEFT', 'side-pre');
To:
define('BLOCK_POS_LEFT', 'top');
But I think a better solution is the use of "sticky" blocks (Moodle > 2.3
required). Have a look at this doc. Here are the different steps:
Now the blocks will appear only on course pages (and not on the front page).
Credits: Re: Block in all Courses in Moodle 2.0. I personally tested it on a Moodle 2.4 installation.
Upvotes: 1