1
利用可能なすべてのコースが表示されるカスタムページを作成しました。コースの画像もアップロードしましたが、今度はコースの名前を画像と共に表示したいと思います。私はデータベースからコースの名前を取得することができますが、イメージを取得する方法。Moodleのカスタムページにコース画像を表示する
利用可能なすべてのコースが表示されるカスタムページを作成しました。コースの画像もアップロードしましたが、今度はコースの名前を画像と共に表示したいと思います。私はデータベースからコースの名前を取得することができますが、イメージを取得する方法。Moodleのカスタムページにコース画像を表示する
あなたはトタラかのMoodleを使用しています。この
// Create a course_in_list object to use the get_course_overviewfiles() method.
require_once($CFG->libdir . '/coursecatlib.php');
$course = new course_in_list($courseid);
$outputimage = '';
foreach ($course->get_course_overviewfiles() as $file) {
if ($file->is_valid_image()) {
$imagepath = '/' . $file->get_contextid() .
'/' . $file->get_component() .
'/' . $file->get_filearea() .
$file->get_filepath() .
$file->get_filename();
$imageurl = file_encode_url($CFG->wwwroot . '/pluginfile.php', $imagepath,
false);
$outputimage = html_writer::tag('div',
html_writer::empty_tag('img', array('src' => $imageurl)),
array('class' => 'courseimage'));
// Use the first image found.
break;
}
}
echo $outputimage;
のようなものを試してみてください? –
Moodle(Version-3.0) –
コースの画像をどのようにアップロードしましたか?それは要約のイメージでしたか? https://docs.moodle.org/30/en/Course_settings#Course_summary_files –