2012-01-15 147 views
0

我正在編寫drupal 7安裝配置文件的過程中,並且無法爲其設置工具欄的某些默認快捷方式,因爲我沒有找到一個要查找的內容其。編寫Drupal 7安裝配置文件

在.install文件,我有這樣的代碼:

// Set Up Shortcuts 
$shortcut_set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME); 
$shortcut_set->links = array(
array(
    'link_path' => 'node/add', 
    'link_title' => st('Add content'), 
    'weight' => -20, 
), 
array(
    'link_path' => 'admin/existing-content', 
    'link_title' => st('Existing content'), 
    'weight' => -19, 
), 
array(
    'link_path' => 'admin/structure/menu/manage/main-menu', 
    'link_title' => st('Menu'), 
    'weight' => -18, 
), 
); 
shortcut_set_save($shortcut_set); 

我如何得到它overrite默認的呢?

+0

會不會在mymodule.module hook_menu是要走的路? http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_menu/7通常mymodule.install處理表的創建,系統變量設置等等。這裏有一些安裝文件相關的掛鉤:hook_schema() module_enable() hook_enable() hook_disable() hook_install() hook_uninstall() hook_modules_installed() – 2012-01-15 00:06:20

+0

不受限制,只要我知道有一個很好看之前的hook_menu選項。 – 2012-01-15 00:10:50

+0

對不起,我起初誤解了你的問題。它是否返回SAVED_NEW或SAVED_UPDATED?確認它沒有更新現有的程序,以便能夠判斷是否有其他模塊可能覆蓋您的代碼。 – 2012-01-15 00:26:52

回答

0

在安裝過程中,創建一個新集並將集名保存在一個變量中。

// Create new short-cut set 
$set = new stdClass(); 
$set->title = 'My Shortcuts'; 
$set->links = array(
    array(
    'link_path' => 'node/add', 
    'link_title' => st('Add content'), 
    'weight' => 1, 
) 
); 

// Save short-cut set 
shortcut_set_save($set); 
variable_set('my_shortcuts', $set->set_name); 

然後在一個模塊中實現「shortcut_default_set」鉤子。

function mymodule_short_default_set($account) 
{ 
    return variable_get('my_shortcuts'); 
}