Imagine v2 theme. Problem with navigation bar

Imagine v2 theme. Problem with navigation bar

by Robert Richmond -
Number of replies: 4
Hi,

I have been modifying the theme made by Julian Ridden, Imagine V2.

I have it all working but I have noticed that the navigation bar seems to have a quirk built into it.

It shows the path to the course, however does not show the course name, instead it shows the value "Array".

An example can be see below:

Arrows

Instead of showing 'Array' (above) it should be showing the course name 06SOSE. Any suggestions as to where I might look in the theme..... (It works fine with other themes, so it must be in the theme somewhere....).



Average of ratings: -
In reply to Robert Richmond

Re: Imagine v2 theme. Problem with navigation bar

by Robert Richmond -
I had a look around and noticed others that have had a similar issue. Now I am not a php expert, so I really have no idea what I'm doing here, but I modified the code like so and it started to work.

From:

<div id="header">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="navbar">
<tr>
<td background="<?php echo "$CFG->wwwroot/theme/$CFG->theme" ?>/pix/top_bg2.gif" height"28">
<div class="navbar clearfix">
<?php
global $course, $category;
if (is_object($course)) {
$nav = $navigation;
$cattree = get_record("course_categories", "id", $course->category);
$linkcss = $cattree->visible ? "" : " class=\"dimmed\" ";
$nav = "<a $linkcss title=\"".htmlspecialchars($cattree->description)."\" "
."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->description)."\" "
."href=\"$CFG->wwwroot/course/category.php?id=$cattree->id\">$cattree->name</a> -> "
.$nav;
}
} else if (is_object($category)) {
$nav = $navigation; // If you want 'course categories' in the breadcrumb, use this.
// $nav = $category->name; // If you don't want 'course categories' in the breadcrumb, use this.
$cattree = $category;
while ($cattree->parent) {
$cattree = get_record("course_categories", "id", $cattree->parent);
$linkcss = $cattree->visible ? "" : " class=\"dimmed\" ";
$nav = "<a $linkcss title=\"".htmlspecialchars($cattree->description)."\" "
."href=\"$CFG->wwwroot/course/category.php?id=$cattree->id\">$cattree->name</a> -> "
.$nav;
}
} else {
$nav = $navigation;
}
$navigation = $nav;
?>
<div class="breadcrumb"><?php print_navigation($navigation); ?></div>
</div>

</td>
</tr>
<tr height="1">
<td class="blueline">
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>


To:

<div id="header">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="navbar">
<tr>
<td background="<?php echo "$CFG->wwwroot/theme/$CFG->theme" ?>/pix/top_bg2.gif" height"28">
<div class="navbar clearfix">
<div class="breadcrumb"><?php print_navigation($navigation); ?></div>
</div>
</td>
</tr>
<tr height="1">
<td class="blueline">
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>

In the process "broke" the path to my courses. It now only shows:
Student Portal > Subject, instead of
Student Portal > Folder 1 > Folder 2 > Subject.

Anyone understand php that might be able to shed some light on the subject?

In reply to Robert Richmond

Re: Imagine v2 theme. Problem with navigation bar - Array Problem

by Robert Richmond -
Anyone?
It would seem that there is a problem in the header.html with the section.

The problem with the code is that it prints out:

"Site name -> Category A -> Category B -> Array "

instead of:

"Site Name -> Category A -> Category B -> Subject Name"

I have narrowed it down to this section....

if (is_object($course)) {
 $nav = $navigation;
 $cattree = get_record("course_categories", "id", $course->category);
 $linkcss = $cattree->visible ? "" : " class=\"dimmed\" ";
 $nav = "<a $linkcss title=\"".htmlspecialchars($cattree->description)."\" "."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->description)."\"
"."href=\"$CFG->wwwroot/course/category.php?id=$cattree->id\">$cattree->name</a>
-> ".$nav; } } I'm not a php expert unfortunately, so I've been unable to narrow it down any further. Could anyone explain why Array prints out instead of the Course name?
In reply to Robert Richmond

Re: Imagine v2 theme. Problem with navigation bar - Array Problem

by Robert Richmond -
Well I have fixed it on my own. Solution was to remove the extra code. (Everything between <?php and ?> ) ....

Code now looks like:
<div id="header">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" class="navbar">
<tr>
<td background="<?php echo "$CFG->wwwroot/theme/$CFG->theme" ?>/pix/top_bg2.gif" height"28">
<div class="navbar clearfix">
<div class="breadcrumb"><?php print_navigation($navigation);?></div>
</div>
</td>
</tr>
<tr height="1">
<td class="blueline">
</td>
</tr>
</table>
</td>
</tr>
</table>

Whilst we could have modified the code to work. We felt it not worth while with the constant upgrades moodle has..It could break it to easily.

Hope this helps someone else.
In reply to Robert Richmond

Re: Imagine v2 theme. Problem with navigation bar - Array Problem

by Daniel Carrasco -
Thanks for documenting this. Helped me out. D.-