Writing Drupal 7 Install Profiles

666 Views Asked by At

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

There are 1 best solutions below

0
Chris On

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');
}