protected function getCategoryPath($categoryID, $pathString = null, $removeLastCategory = false) { global $DB; if (is_null($pathString)) { $pathString = $DB->get_field('course_categories', 'path', array('id' => $categoryID)); } $categoryIDs = explode('/', $pathString); //Remove the first item //(will be empty because the path string starts with /) array_shift($categoryIDs); if ($removeLastCategory) { //Remove the last item //(would cause the name to be duplicated if shown for a category result) array_pop($categoryIDs); } if (count($categoryIDs) < 1) { return array(); } $path = array(); foreach ($categoryIDs as $categoryID) { // This is really an SSIS tweak, but if your Moodle has this function to find // and icon to use for a category it should return the name of a fontawesome 4 icon here if (function_exists('\\course_get_category_icon')) { $categoryIcon = \course_get_category_icon($categoryID); } else { $categoryIcon = false; } $path[] = array('title' => 'Category', 'name' => $DB->get_field('course_categories', 'name', array('id' => $categoryID)), 'url' => new moodle_url('/course/index.php', array('categoryid' => $categoryID)), 'icon' => !empty($categoryIcon) ? 'fa fa-' . $categoryIcon : 'fa fa-folder-open'); } return $path; }
public function icon() { if (function_exists('\\course_get_category_icon')) { $categoryIcon = \course_get_category_icon($this->row->id); return html_writer::tag('i', '', array('class' => 'fa fa-' . $categoryIcon)); } else { return html_writer::tag('i', '', array('class' => 'fa fa-folder-open')); } }