Sunday 9 November 2014

Moodle: get top category from course data

Hello!

If we have course data and we want to get top category from that, we can do this:

$category = $DB->get_record('course_categories', array('id' => $courseObj->category));
$arrCats = explode("/", ($category->path));
$topCategory = $DB->get_record('course_categories', array('id' => intval($arrCats[1])));


Best regards!

No comments:

Post a Comment