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.
This commit is contained in:
+7
-4
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user