如何在 Moodle 的页面中心添加一个块? [英] How to add a block to the center of a page in Moodle?

查看:37
本文介绍了如何在 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屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆