我想将自定义链接添加到网站管理文件夹(顶级),如下所示:
网站管理
- 我的自定义链接1
- 我的自定义链接2
..然后去标准moodle
- 通知
- 依此类推......
到目前为止,我能够将自定义链接添加到主导航块,并且在管理块内部,但是在站点管理文件夹中没有办法。现在我正在使用$ settings = get_config('local_custom_links)从设置中获取菜单项');
如果你想在Block Administration中添加链接,它会很有效。但是如果有人成功添加了链接到Site Administration文件夹,请提供帮助。
这是我的代码:
function local_custom_links_extend_settings_navigation(settings_navigation $nav, context $context) {
$settings = get_config('local_custom_links');
if (!empty($settings->menuitems_site_administration) && $settings->enable_site_administration) {
$menu = new custom_menu($settings->menuitems_site_administration, current_language());
if ($menu->has_children()) {
foreach ($menu->get_children() as $item) {
custom_links_settings_item($item, 0, null, $nav);
}
}
}
}
function custom_links_settings_item(custom_menu_item $menunode, $parent, $pmasternode, settings_navigation $nav) {
global $PAGE, $CFG;
static $submenucount = 0;
if ($menunode->has_children()) {
$submenucount++;
$url = $CFG->wwwroot;
if ($menunode->get_url() !== null) {
$url = new moodle_url($menunode->get_url());
} else {
$url = null;
}
if ($parent > 0) {
$masternode = $pmasternode->add($menunode->get_text(), $url, navigation_node::TYPE_CONTAINER);
} else {
$masternode = $nav->add($menunode->get_text(), $url, navigation_node::TYPE_CONTAINER);
}
foreach ($menunode->get_children() as $menunode) {
lambda_custom_links_custom_menu_item($menunode, $submenucount, $masternode, $nav);
}
}
}
答案 0 :(得分:0)
使用此
在settings.php
文件夹中创建/local/custom_links
文件
defined('MOODLE_INTERNAL') || die;
if ($hassiteconfig) {
$ADMIN->add(
'root', // Root is the top menu.
new admin_externalpage(
'local_custom_links', // Unique name.
get_string('pluginmenu', 'local_custom_links'), // Human name.
new moodle_url('/local/custom_links/index.php'), // Link.
'local/custom_links:manage' // Capability if any.
)
);
}
答案 1 :(得分:0)
我成功添加了一个包含少量自定义链接的文件夹,现在我需要弄清楚如何将它放在网站管理的顶部:
$ADMIN->add('root', new admin_category('local_custom_links', 'Platform'));
$ADMIN->add('local_custom_links', new admin_settingpage('local_custom_link_1', 'navigation 1',
$CFG->wwwroot.'/local/settings/navigation.php'));
$ADMIN->add('local_custom_links', new admin_externalpage('local_custom_link_2', 'navigation 2',
$CFG->wwwroot.'/local/settings/navigation.php'));
$ADMIN->add('local_custom_links', new admin_externalpage('local_custom_link_3', 'navigation 3',
$CFG->wwwroot.'/local/settings/navigation.php'));
$ADMIN->add('local_custom_links', new admin_externalpage('local_custom_link_4', 'navigation 4',
$CFG->wwwroot.'/local/settings/navigation.php'));
$ADMIN->add('local_custom_links', new admin_externalpage('local_custom_link_5', 'navigation 5',
$CFG->wwwroot.'/local/settings/navigation.php'));