/// Print out all the sub-categories
- if ($subcategories = get_records("course_categories", "parent", $category->id)) {
+ if ($subcategories = get_records("course_categories", "parent", $category->id), "sortorder ASC") {
$firstentry = true;
foreach ($subcategories as $subcategory) {
if ($subcategory->visible or iscreator()) {
function print_whole_category_list($category=NULL, $displaylist=NULL, $parentslist=NULL, $depth=-1) {
/// Recursive function to print out all the categories in a nice format
/// with or without courses included
+ global $CFG;
+ if (isset($CFG->max_category_depth)&&($depth >= $CFG->max_category_depth)) {
+ return;
+ }
if (!$displaylist) {
make_categories_list($displaylist, $parentslist);
echo "<td class=\"categoryname\"> </td>";
echo "</tr>\n";
- if ($courses) {
+ if ($courses && !(isset($CFG->max_category_depth)&&($depth>=$CFG->max_category_depth-1))) {
foreach ($courses as $course) {
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
echo "<tr><td valign=\"top\" width=\"30\"> ";