3

我需要在 Moodle 2.x 主题设置中创建一个元素列表,为此我将使用 Moodle 包含的 YUI 启用拖放重新排序。我的问题是我不知道如何使用自定义主题设置添加自定义 HTML/JS。我只能找到有关使用 Moodle 提供的预定义功能添加设置的文档,例如admin_setting_configtextoradmin_setting_configselectadmin_setting_configtextarea​​... 我如何创建自己的标记并在主题设置页面中使用自己的 javascript?谢谢!

4

1 回答 1

3

You can create a custom page using Moodle, remember to require the config and set up the page:

require('../../../config.php');
require_once($CFG->libdir.'/adminlib.php');
//page definition
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
$PAGE->set_url('/theme/your_theme/admin/manage.php');
$PAGE->set_pagetype('theme_name_manage');
$PAGE->set_title('Manage your theme');
$PAGE->set_heading('Manage your theme');
echo $OUTPUT->header();
//Page content
echo $OUTPUT->footer();

From this page you can define whatever setup or configuration you want. Finally you will want to add this page to the site admin navigation. Make sure you have a settings.php in the root directory of your theme and within that file you'll be wanting something like this:

if ($hassiteconfig) { // needs this condition or there is error on login page
    $ADMIN->add('themes', new admin_externalpage('theme_name', 
        'Manage Theme XYZ', 
        $CFG->wwwroot."/theme/name/admin/manage.php", 
        'moodle/site:config'));
}

Themes being the reference for the "themes" admin menu I figure you probably want to add this to. Remember that you should be using get_string in the above examples instead of hard-coding strings.

于 2012-11-20T10:30:59.440 回答