一个简单的方法是在首页布局中创建一个中心区域,并且应该在 Moodle 中创建为默认设置。
然后,当您将块(带有您的论坛主题代码)添加到首页时,只需将其移动到中心区域即可。
以下是创建区域的方法:
在/theme/themename/config.php
首页区域添加“中心帖子”。
'frontpage' => array(
'file' => 'default.php',
'regions' => array('side-pre', 'side-post', 'center-post'),
'defaultregion' => 'side-pre',
'options' => array('langmenu'=>true),
),
在/theme/themename/lang/en/theme_themename.php
为区域名称添加一个字符串
$string['region-center-post'] = 'Center Bottom';
在/theme/themename/layout/default.php
添加 $hasscenterpost 行:
$hassidepost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-post', $OUTPUT));
// Add this line.
$hascenterpost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('center-post', $OUTPUT));
$haslogininfo = (empty($PAGE->layout_options['nologininfo']));
然后在region-content
div之后,添加if ($hascenterpost)
代码:
<div id="region-main">
<div class="region-content">
<?php echo $coursecontentheader; ?>
<?php echo $OUTPUT->main_content() ?>
<?php echo $coursecontentfooter; ?>
</div>
<?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 } ?>
</div>
您可能还需要增加版本号/theme/themename/version.php
。