如何在 Moodle 的页面中心添加一个块? [英] How to add a block to the center of a page in Moodle?
问题描述
我想在活动下方而不是在左侧或右侧栏上显示评论块.
这比我想象的要容易得多.
我为 center-post 添加了代码,它将在主要内容的底部添加一个块.它可以很容易地修改为在主要内容的顶部显示一个 center-pre.
在/theme/yourthemename/config.php
在需要的每个页面布局的 region() 数组中添加 'center-post'.例如,模块仅将其添加到incourse"布局
//当然是模块的一部分 - 如果 $cm 特定,则默认页面布局'incourse' =>大批('文件' =>'general.php','地区' =>array('side-pre', 'side-post', 'center-post'),'默认区域' =>'侧前',),
在/theme/yourthemename/lang/en/theme_yourthemename.php中添加
$string['region-center-post'] = '中心底部';
在/theme/yourthemename/layout/general.php
在 $hassidepost 之后的顶部附近 ... 添加
$hascenterpost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('center-post', $OUTPUT));
然后查找 MAIN_CONTENT_TOKEN 并添加
<?php echo core_renderer::MAIN_CONTENT_TOKEN ?>//添加这个<?php if ($hascenterpost) { ?><div id="region-center-post" class="block-region"><div class="region-content"><?php echo $OUTPUT->blocks_for_region('center-post');?>
<?php } ?>//添加结束<?php echo $coursecontentfooter;?>
现在转到一个模块,向模块添加一个块,您可以选择将块移动到中心底部.
I wanted to display a comment block below the activity rather than on the left or right side bars.
It was a lot easier than I thought.
I've added code for center-post which will add a block at the bottom of the main content. It could easily be modified to have a centre-pre for displaying at the top of the main content.
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.
这篇关于如何在 Moodle 的页面中心添加一个块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!