1
有沒有辦法在Moodle中永久顯示一個塊?我正在配置一個主題,我想知道是否有一種方法可以確保無論您在哪個頁面上都可以看到塊。在Moodle中永久顯示區塊?
有沒有辦法在Moodle中永久顯示一個塊?我正在配置一個主題,我想知道是否有一種方法可以確保無論您在哪個頁面上都可以看到塊。在Moodle中永久顯示區塊?
一個解決方案應該是添加一個新的塊區域。
在你主題目錄,在config.php文件,修改佈局選項和新的區域添加到所有使用的佈局:
$THEME->layouts = array(
'base' => array(
'file' => 'admin.php',
'regions' => array('your-region'),
'defaultregion' => 'your-region',
),
'standard' => array(
'file' => 'admin.php',
'regions' => array('your-region', 'side-post'),
'defaultregion' => 'your-region',
),
// The site home page.
'frontpage' => array(
'file' => 'general.php',
'regions' => array('tools-menu', 'side-post'),
'defaultregion' => 'tools-menu',
'defaultregion' => 'tools-menu',
),
'course' => array(
'file' => 'general.php',
'regions' => array('your-region'),
'defaultregion' => 'your-region',
'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true),
),
etc...
然後就可以編輯所有的佈局文件theme/your_theme/layout/*.php
和您希望您的塊出現加入這一行:
echo $OUTPUT->blocks_for_region('your-region');
現在,你將不得不添加你的塊到這個區域的所有頁面類型,只需在你的數據庫中執行這個sql:
INSERT INTO `mdl_block_instances` (
`id` ,
`blockname` ,
`parentcontextid` ,
`showinsubcontexts` ,
`pagetypepattern` ,
`subpagepattern` ,
`defaultregion` ,
`defaultweight` ,
`configdata`
)
VALUES (NULL , 'your_block_name', '1', '1', '*', NULL, 'your-region', '0', NULL);