How to add a block to the center of a page in Moodle?

▼魔方 西西 提交于 2019-12-04 19:44:45

In /theme/yourthemename/config.php

Add 'centre-post' to the regions() array for each page layout where it is required. Eg for modules only added it to 'incourse' layout

 // Part of course, typical for modules - default page layout if $cm specifi
 'incourse' => array(
     'file' => 'general.php',
     'regions' => array('side-pre', 'side-post', 'center-post'),
     'defaultregion' => 'side-pre',
 ),

In /theme/yourthemename/lang/en/theme_yourthemename.php add

$string['region-center-post'] = 'Center Bottom';

In /theme/yourthemename/layout/general.php

near the top after $hassidepost ... add

$hascenterpost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('center-post', $OUTPUT));

then look for MAIN_CONTENT_TOKEN and add

<div class="region-content"> <?php echo core_renderer::MAIN_CONTENT_TOKEN ?> </div>
// Add this
<?php if ($hascenterpost) { ?>
<div id="region-center-post" class="block-region">
<div class="region-content">
<?php echo $OUTPUT->blocks_for_region('center-post'); ?>
</div>
</div>
<?php } ?>
// End of add this
<?php echo $coursecontentfooter; ?>

Now go to a module, add a block to the module and you will have a choice to move the block to the centre bottom.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!