编写Drupal 7安装配置文件
问题描述:
我正在编写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默认的呢?
答
在安装过程中,创建一个新集并将集名保存在一个变量中。
// 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');
}
会不会在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
不受限制,只要我知道有一个很好看之前的hook_menu选项。 – 2012-01-15 00:10:50
对不起,我起初误解了你的问题。它是否返回SAVED_NEW或SAVED_UPDATED?确认它没有更新现有的程序,以便能够判断是否有其他模块可能覆盖您的代码。 – 2012-01-15 00:26:52