我需要更改Moodle 2.5.3中的痕迹导航,只显示指向层次结构中最后一页的链接。我怎么能这样做?
答案 0 :(得分:1)
在你的主题中你应该override the core renderer,特别是navbar()函数。
目前还不清楚最后一页的含义 - 用户来自的最后一页或生成的跟踪中的最后一个链接。
后一种情况比较容易,所以我先处理 - 你可以使用here中的以下内容:
/*
* This renders the navbar.
* Uses bootstrap compatible html.
*/
public function navbar() {
$is_course = false;
$items = $this->page->navbar->get_items();
//If this is a course, only output the course node and the last link node (if any)
// (e.g. $item->action is not null)
foreach ($items as $item) {
if (!$is_course) {
$is_course = (navigation_node::TYPE_COURSE == $item->type);
}
}
if ($is_course) {
//Only output some nodes
$last_node_found = false;
$items = array_reverse($items);
foreach ($items as $item) {
//Only output crumbs with links
if (navigation_node::TYPE_COURSE == $item->type ||
(!$last_node_found && $item->action)) {
$last_node_found = true;
$item->hideicon = true;
$breadcrumbs[] = $this->render($item);
}
if (navigation_node::TYPE_COURSE == $item->type) {
//We're done here
break;
}
}
$breadcrumbs = array_reverse($breadcrumbs);
}
else {
//Output all navigation nodes
foreach ($items as $item) {
$item->hideicon = true;
$breadcrumbs[] = $this->render($item);
}
}
$divider = '<span class="divider">/</span>';
$list_items = '<li>'.join(" $divider</li><li>", $breadcrumbs).'</li>';
$title = '<span class="accesshide">'.get_string('pagepath').'</span>';
return $title . "<ul class=\"breadcrumb\">$list_items</ul>";
}
基本上给出了相反的项目列表,然后测试每个项目是否是链接及其类型。其他人被忽略了。
在前一种情况下,您可以使用$ _SERVER ['HTTP_REFERER']作为链接,或者您需要向会话写入信息以获取页面的URL和名称,如果这还不够。
答案 1 :(得分:0)
您可以使用css解决此问题。类似的东西:
.breadcrumb li {
display: none;
/* other css code */
}
.breadcrumb li:last-child {
display: block;
}