Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a parameter to print_courses() to hide site course

This parameter is used in index.php because if the moodle site have more than one category the site course will be displayed in the course list in the front page.

This problem appeared after the "front page format" feature is introduced. As the old front page will show a category tree with courses if there are more than one category in the system when "list of courses" is chosen as the front page.
  • Loading branch information...
commit 8e227aa7670ed02f51cbb3719e893a83aa75d340 1 parent bfb55c1
patrickslee authored
Showing with 8 additions and 5 deletions.
  1. +7 −4 course/lib.php
  2. +1 −1  index.php
View
11 course/lib.php
@@ -1373,7 +1373,7 @@ function print_category_info($category, $depth) {
}
-function print_courses($category, $width="100%") {
+function print_courses($category, $width="100%", $hidesitecourse = false) {
/// Category is 0 (for all courses) or an object
global $CFG;
@@ -1382,18 +1382,21 @@ function print_courses($category, $width="100%") {
$categories = get_categories(0); // Parent = 0 ie top-level categories only
if (count($categories) == 1) {
$category = array_shift($categories);
- $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency');
+ $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.category,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency');
} else {
- $courses = get_courses('all', 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency');
+ $courses = get_courses('all', 'c.sortorder ASC', 'c.id,c.category,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency');
}
unset($categories);
} else {
$categories = get_categories($category->id); // sub categories
- $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency');
+ $courses = get_courses($category->id, 'c.sortorder ASC', 'c.id,c.category,c.sortorder,c.visible,c.fullname,c.shortname,c.password,c.summary,c.teacher,c.cost,c.currency');
}
if ($courses) {
foreach ($courses as $course) {
+ if ($hidesitecourse && !$course->category) {
+ continue;
+ }
print_course($course, $width);
}
} else {
View
2  index.php
@@ -156,7 +156,7 @@
print_my_moodle();
} else {
print_heading_block(get_string('availablecourses'));
- print_courses(0, '100%');
+ print_courses(0, '100%', true);
}
break;
Please sign in to comment.
Something went wrong with that request. Please try again.