Commented in Moodle's forum: http://moodle.org/mod/forum/discuss.php?d=2627
if ($categories = get_categories("$category->id")) { // Print all the children recursively
foreach ($categories as $cat) {
if (!empty($category->id)) {
- $parents[$cat->id] = $parents[$category->id];
+ if (!empty($parents[$category->id])) {
+ $parents[$cat->id] = $parents[$category->id];
+ }
$parents[$cat->id][] = $category->id;
}
make_categories_list($list, $parents, $cat, $path);