Avoid calling categories in every loop.

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent af34a182b3
commit 268f651ede
  1. 10
      main/template/default/auth/courses_categories.php

@ -150,6 +150,8 @@ if ($showCourses && $action != 'display_sessions') {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$user_id = api_get_user_id();
$categoryList = CourseManager::getCategoriesList();
if (!empty($browse_courses_in_category)) {
foreach ($browse_courses_in_category as $course) {
$course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN;
@ -175,6 +177,8 @@ if ($showCourses && $action != 'display_sessions') {
// display the course bloc
$html .= '<div class="col-xs-6 col-sm-6 col-md-3"><div class="items items-courses">';
$course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : '';
// display thumbnail
$html .= returnThumbnail($course);
@ -267,6 +271,7 @@ echo $cataloguePagination;
/**
* Display the course catalog image of a course
* @param array $course
*
* @return string HTML string
*/
function returnThumbnail($course)
@ -285,10 +290,8 @@ function returnThumbnail($course)
$html .= '<div class="image">';
$html .= '<img class="img-responsive" src="'.$course_medium_image.'" alt="'.api_htmlentities($title).'"/>';
$categoryTitle = isset($course['category']) ? $course['category'] : '';
$categoryTitle = isset($course['category_title']) ? $course['category_title'] : '';
if (!empty($categoryTitle)) {
$listCategory = CourseManager::getCategoriesList();
$categoryTitle = $listCategory[$categoryTitle];
$html .= '<span class="category">'. $categoryTitle.'</span>';
$html .= '<div class="cribbon"></div>';
}
@ -317,7 +320,6 @@ function returnThumbnail($course)
return $html;
}
/**
* Display the title of a course in course catalog
* @param $course

Loading…
Cancel
Save