2012-09-28 51 views

回答

1

一個解決方案應該是添加一個新的塊區域。
在你主題目錄,在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);