I created cutom category view on my moodle home page.
It looks like this:
As you can see it contrain course counter.
If you want some similar, here you have few steps to do
1. Add new function to /moodle/course/lib.php
//course counter
function _zliczKursy($id) {
global $DB;
$sum = 0;
$result = $DB->get_records_sql("SELECT `id`, `coursecount`, `parent` FROM `mdl_course_categories` WHERE `parent`='".$id."'");
foreach($result as $obj) {
$sum += $obj->coursecount;
if( !empty($obj->parent) ) {
$sum += _zliczKursy($obj->id);
}
}
return $sum;
}
// display icons
function wyswietlIkony($category, $depth=0) {
global $DB;
if( $depth != 0 ) return false;
echo '<div style="float: left; margin: 20px; padding: 5px; text-align: center; font-weight: bold; width: 130px; height: 100px;">';
$ico = '../ikony/'.strtr( strtolower($category->id), ' ', '_' ).'.png';
if( !file_exists($ico) ) {
//$ico = '#'; // missing icon
}
$link = '<img src="'.$ico.'" title="'.$category->name.'" height="70" width="70" >';
$link .= '<br />'.$category->name;
$url = new moodle_url('/course/category.php', array('id'=>$category->id));
echo html_writer::link($url, html_writer::link($url, $link));
$sum = 0;
$result = $DB->get_records_sql("SELECT `coursecount` FROM `mdl_course_categories` WHERE `id`='".$category->id."'");
foreach($result as $obj) {
$sum += $obj->coursecount;
}
$sum += _zliczKursy($category->id);
//if( $sum ) {
echo ' ('.$sum.')';
//}
echo '</div>';
}
2. In course/lib.php
After lines
if ($category->visible or
has_capability('moodle/category:viewhiddencategories',
get_context_instance(CONTEXT_SYSTEM))) {
You have to comment line
print_category_info($category, $depth, $showcourses);
and add new one
wyswietlIkony($category, $depth);
3. In moodle/index.php
After lines:
echo $OUTPUT->skip_link_target();
print_whole_category_list();
You have to add new line:
echo '<div style="clear:both"></div>';
4. You need to create new folder for category icons. In this case it's "ikony"
5. You need to copy your new category icons to moode/ikony
6. Icons names must looks like this: moode_category_ID.png, eg. 114.png
7. Now you need to turn on our custom categories view in Moodle: Site administration => Front page => front page settings => in front page frontpage or/and front page items when logged in set from list: List of categories
One BUG: You need to decide how to put your courses into categories. You can put it into main categories or under subcategories. You can't choce both becouse couner would fail.