【问题标题】:How to create custom markup in Moodle theme settings?如何在 Moodle 主题设置中创建自定义标记?
【发布时间】:2012-11-19 16:54:09
【问题描述】:

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

【问题讨论】:

    标签: themes settings moodle


    【解决方案1】:

    您可以使用 Moodle 创建自定义页面,记得要求配置并设置页面:

    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();
    

    在此页面中,您可以定义您想要的任何设置或配置。最后,您需要将此页面添加到站点管理导航中。确保您在主题的根目录中有一个 settings.php,并且在该文件中您会想要这样的内容:

    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'));
    }
    

    主题 是“主题”管理菜单的参考,我想您可能想将其添加到其中。请记住,您应该在上面的示例中使用 get_string 而不是硬编码字符串。

    【讨论】:

      猜你喜欢
      • 2013-01-22
      • 1970-01-01
      • 2018-05-18
      • 2018-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-24
      • 1970-01-01
      相关资源
      最近更新 更多