0
votes

I am in the process of writing a drupal 7 install profile and am having trouble with a getting it to set up some default shortcuts for the tool bar as I do not one the find content one to be in their.

In the .install file I have this code:

// 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);

How do I get it to overrite the default ones?

1
wouldn't hook_menu in the mymodule.module be the way to go? api.drupal.org/api/drupal/modules--system--system.api.php/… generally mymodule.install handles things like table creation, system variable setting, etc. here are some hooks related to install files: hook_schema() module_enable() hook_enable() hook_disable() hook_install() hook_uninstall() hook_modules_installed() - Milo LaMar
Not as far as I'm aware had a good look the hook_menu options before. - Chris Archer
Sorry I misunderstood your question at first. Is it returning SAVED_NEW or SAVED_UPDATED? Confirm that it is not updating your existing one to be able to tell if another module might be overriding your code. - Milo LaMar
Which hook are you running this code in? - Clive
Sorry how do I find this out, I'm using Aegir to install the install profile - Chris Archer

1 Answers

0
votes

During the installation, create a new set and save the set name in a variable.

// 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);

Then in a module, implement the "shortcut_default_set" hook.

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