function course_iframe in Course 3.x
Same name and namespace in other branches
- 8.3 course.module \course_iframe()
- 8.2 course.module \course_iframe()
- 6 course.module \course_iframe()
- 7.2 course.module \course_iframe()
- 7 course.module \course_iframe()
Generic Course IFrame function.
Parameters
string $url: An iframe HTML element src attribute.
string $height: A string representing an iframe height.
string $class: A HTML class attribute for the iframe.
1 call to course_iframe()
- CourseObject::takeObject in src/
Entity/ CourseObject.php - Take a course object.
File
- ./
course.module, line 346 - course.module Core functionality for Courses.
Code
function course_iframe($url = NULL, $height = '600px', $class = NULL) {
$style = 'border:none; margin:0; width:100%; height:' . $height . ';';
// Add JS to resize parent frame. This assumes additional JS on the targeted iframe content.
// @todo
// drupal_add_js(drupal_get_path('module', 'course') . '/js/resizeframe.js');
return [
'#type' => 'html_tag',
'#tag' => 'iframe',
'#attributes' => [
'id' => 'course-viewer',
'src' => $url
->toString(),
'class' => [],
'scrolling' => 'no',
'frameborder' => 'no',
'onload' => 'resizeFrame(this);',
'style' => $style,
],
];
}