0

我正在研究 moodle 2.8 和基本主题现在我想设置我的主页以显示论坛主题。从渲染文件夹中的frontpage.php我可以看到他们使用get_setting函数来渲染项目,但我无法找到在哪里以及如何使用这个函数在主页中显示论坛页面,因为我复制了呈现主页的代码但是我想我的 argomas 不是真的,所以这个 get 设置不起作用,现在提前显示任何东西 ty `

if ($showfrontcontent) { ?>
            <div class="frontpagecontent">
                <?php
                echo $OUTPUT->get_setting('frontcontentarea', 'format_html');
                echo $OUTPUT->get_setting('mod_forum', 'format_html');
                echo $OUTPUT->essential_edit_button('theme_essential_frontpage');
                ?>

            </div>`
4

1 回答 1

0

一个简单的方法是在首页布局中创建一个中心区域,并且应该在 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-contentdiv之后,添加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

于 2015-08-16T12:57:56.573 回答