我正在尝试将 moodle 与我自己的 PHP 应用程序集成。是否可以在 iframe 中显示 moodle 网站?
2 回答
在您的站点管理中,检查配置变量“allowframembedding”。它位于站点管理 > 安全 > HTTP 安全中。
默认情况下“允许嵌入框架”设置为“否”,只需单击复选框以启用 Moodle 嵌入到 iframe 中。
My problem was that I could save an iframe in the editor, but that iframe was stripped upon later edit. If you're experiencing problems embedding the iframe in blogs or forums, here is a piece of code that I used in moodle 3.9.1: edit config.php, search for
require_once(__DIR__ . '/lib/setup.php');
then exaclty under it put the following code:
$script_file = realpath($_SERVER['SCRIPT_FILENAME']);
if($script_file){
$script_file_rel_path = substr($script_file,strlen(__DIR__));
if(strpos($script_file_rel_path,'/edit.php') !== false){
$sitecontext = context_system::instance();
if(has_capability('moodle/site:trustcontent',$sitecontext)){
require_once __DIR__ . '/lib/htmlpurifier/HTMLPurifier.safe-includes.php';
require_once __DIR__ . '/lib/htmlpurifier/HTMLPurifier/ConfigSchema.php';
$definition = HTMLPurifier_ConfigSchema::instance();
$definition->add('HTML.SafeIframe', true, 'bool', true);
// Only allow urls from subdomains of google.com and youtube.com
$definition->add('URI.SafeIframeRegexp', '/:\/\/([^\/]*?)(\.(google|youtube)\.com)\//','string', true);
// Uncomment the following and remove previous line in order to allow any url in the "src" attribute
// $definition->add('URI.SafeIframeRegexp', '//','string', true);
}
}
}
What this does is: users that have the capability: moodle/site:trustcontent in the system, when accessing edit.php links (editing pages) will be able to embed iframes in their texts editors with urls from specific domains.