Skip to content

Instantly share code, notes, and snippets.

@d1i1m1o1n
Created May 14, 2015 14:55
Show Gist options
  • Save d1i1m1o1n/cf1532e3238b670644cb to your computer and use it in GitHub Desktop.
Save d1i1m1o1n/cf1532e3238b670644cb to your computer and use it in GitHub Desktop.
Moodle. Получаем список курсов с картинками.
<div class="courses">
<?$courses = get_courses();?>
<h1>Доступные курсы</h1>
<div class="courses-blocks">
<?foreach ($courses as $key => $course):?>
<?if( ! empty($course->idnumber)):
if ($course instanceof stdClass) {
require_once($CFG->libdir. '/coursecatlib.php');
$course = new course_in_list($course);
}
?>
<div class="courses-block">
<p class="courses-block-title"><?=$course->fullname?></p>
<?foreach ($course->get_course_overviewfiles() as $file):
$isimage = $file->is_valid_image();
$url = file_encode_url("$CFG->wwwroot/pluginfile.php",
'/'. $file->get_contextid(). '/'. $file->get_component(). '/'.
$file->get_filearea(). $file->get_filepath(). $file->get_filename(), !$isimage);
if ($isimage):
?>
<img class="image" src="<?=$url?>" width="275px"/>
<?endif;?>
<?endforeach;?>
<a href="course/view.php?id=<?=$course->id?>" title="<?=strip_tags($course->summary)?>">Пройти пробный курс</a>
</div>
<?endif;?>
<?endforeach;?>
</div>
<div style="display:none;"><?echo $OUTPUT->main_content();?></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment