We use the code pasted below in the header.html file of our custom theme to show the categories in the breadcrumb (navigation). We have removed the " 's around $navigation as is required in 1.9, however when we leave the code for the category, the course still appears as 'array' in the breadcrumb. Can someone please point out what we need to change in the category bit...? Thanks
Here is the code:
<?php //Accessibility: breadcrumb trail/navbar now a DIV, not a table.
if ($navigation) { // This is the navigation bar with breadcrumbs
/////////////////////////////////////////////////////////////////////
// to add the category name in the breadcrumb //
/////////////////////////////////////////////////////////////////////
global $course, $category;
if (is_object($course)) {
$nav = $navigation;
if ($cattree = get_record("course_categories", "id", $course->category)) {
$linkcss = $cattree->visible ? "" : " class=\"dimmed\" ";
if (isset($cattree->name)) {
$nav = "<a $linkcss title=\"".htmlspecialchars($cattree->name)."\" "
."href=\"$CFG->wwwroot/course/category.php?id=$cattree->id\">$cattree->name</a> -> "
.$nav;
}
while ($cattree->parent) {
$cattree = get_record("course_categories", "id", $cattree->parent);
$linkcss = $cattree->visible ? "" : " class=\"dimmed\" ";
$nav = "<a $linkcss title=\"".htmlspecialchars($cattree->name)."\" "
."href=\"$CFG->wwwroot/course/category.php?id=$cattree->id\">$cattree->name</a> -> "
.$nav;
}
}
} else if (is_object($category)) {
//$nav = $navigation; // If you want the string 'course categories' in the breadcrumb, use this.
$nav = $category->name; // If you don't want the string 'course categories' in the breadcrumb, use this.
if ($cattree = $category) {
while ($cattree->parent) {
$cattree = get_record("course_categories", "id", $cattree->parent);
$linkcss = $cattree->visible ? "" : " class=\"dimmed\" ";
$nav = "<a $linkcss title=\"".htmlspecialchars($cattree->name)."\" "
."href=\"$CFG->wwwroot/course/category.php?id=$cattree->id\">$cattree->name</a> -> "
.$nav;
}
}
} else {
$nav = $navigation;
}
$navigation = $nav;
/////////////////////////////////////////////////////////////////////
// end of: to add the category name in the breadcrumb //
/////////////////////////////////////////////////////////////////////
?>
<div class="navbar clearfix">
<div class="breadcrumb"><?php print_navigation($navigation); ?></div>
<div class="navbutton"><?php echo $button; ?></div>
</div>
<?php } else if ($heading) { // If no navigation, but a heading, then print a line
?><?php } ?>
<!-- END OF HEADER -->
<div id="content" style="padding : 10px">