Blocks in the center region - Moodle 2.0

Blocks in the center region - Moodle 2.0

by Monica Soori -
Number of replies: 7

I believe moodle 2.0 supports blocks to be added to the center region. I am not able to find good documentation on this topic.

Once I log in , I want to have a block displayed in the course/categories list section in the center to show my custom block. Pl suggest.

Average of ratings: -
In reply to Monica Soori

Re: Blocks in the center region - Moodle 2.0

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Erm- I am not sure about this; I will go and check it out. Could you clarify a bit more what you mean and maybe there is a workaround or something already possible?
(edit) Ok -back smile At present centre blocks are only available on the MyMoodle page in Moodle 2.0. Would that help?
Attachment centreblocks2.png
In reply to Mary Cooch

Re: Blocks in the center region - Moodle 2.0

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Actually, "Where can blocks go on the page?" is a decision that is up to the theme you use. However, I don't think anyone has yet made a theme that offers anything other than left and right. Perhaps the Moodle 2.0 theme competition will encourage someone to be creative?

In addition, as you spotted, certain pages can choose to make extra regions visible. My hope was that some other pages, like the site front page, and the category pages, would let you customise the contents by putting any blocks you like in the middle, but I don't think that has been implemented. (What really needs to be duplicated are blocks that replicate what currently goes in the middle of those pages, so we can use those blocks instead of the current code.
In reply to Mary Cooch

Re: Blocks in the center region - Moodle 2.0

by franziss franziss -

I am trying to add a block "question" which I have created, to the center of my moodle page. But my block "question" is not shown under the "Add a block" of my moodle page

Why is it so? My block "question" is allowed to be added under the course and main moodle page.

In reply to franziss franziss

Re: Blocks in the center region - Moodle 2.0

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

There is not much you can do with a block, if you can move it then you are restricted to only the areas indicated in Mary Cooch's comment earlier in this discussion. In your case you can only move the block within the course you created it in. You cannot reasign it to a new location. Neither will it show up in the Add Block dropdown list.

Mary

In reply to Mary Evans

Re: Blocks in the center region - Moodle 2.0

by franziss franziss -

Thank you for your reply Mary. Is there a simple way to place a block in the center of the page? I read somewhere that some themes support this. Do you have any idea which themes allow this? Thank you for your kind help.

In reply to franziss franziss

Re: Blocks in the center region - Moodle 2.0

by Guy Thomas -
Picture of Core developers Picture of Plugin developers

Any theme can be easily modified to allow for blocks to be placed in the main region of the front page. This is what I did to modify the standard them to work this way:

Step 1 - Modify [yourtheme]/layout/general.php

put <?php echo $OUTPUT->blocks_for_region('main') ?> under <?php echo $OUTPUT->main_content() ?>

e.g.

                <div id="region-main-wrap">
                    <div id="region-main">
                        <div class="region-content">
                            <?php echo $OUTPUT->main_content() ?>
                            <?php echo $OUTPUT->blocks_for_region('main') ?>
                        </div>
                    </div>
                </div>

Step 2 - Modify [yourtheme]/config.php

// apply same layout to each possible layout type
$layouts=array('standard','course','coursecategory','incourse','frontpage','admin','mydashboard','mypublic','popup','frametop','embedded','maintenance','print');
foreach ($layouts as $layout){
    $THEME->layouts[$layout]= array(
        'file' => 'general.php',
        'regions' => array('side-post','main'),
        'defaultregion' => 'side-post',
    );
}

In reply to Guy Thomas

Re: Blocks in the center region - Moodle 2.0

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Thanks for updating that post Guy, but you missed off some other important things too like...

$hasregionmain = $PAGE->blocks->region_has_content('main', $OUTPUT);

in theme/themename/layout/frontpage.php, general.php and report.php

and also...

$string['regionmain'] = 'Center';

which needs adding to theme/themname/lang/en/theme_themename.php

Cheers

Mary