In my installation profile, I am trying to add a menu link for the /import path (from feed_import module). menu_link_save() works for all my menu paths with the exception of /import. Anyone have ideas why?

So, this works and creates a menu path to /user:

$link = array('menu_name' => 'menu-authenticated', 'link_path' => 'user', 'link_title' => 'Account');

But this does not:

$link = array('menu_name' => 'menu-authenticated', 'link_path' => 'import', 'link_title' => 'Import');

After installation is finished, /import path works (feeds_import is installed and enabled in the installation profile), but the menu link was not created.

Any help would be much appreciated. Thanks!

  • I think this is because the moment you try to create "import" menu item, the menu item doens't exsist yet. I think your code gets executed too early
    – Robin
    Commented Nov 1, 2014 at 9:07
  • If you put the menu link on a feature the menu link will be created. I know that it's not you are looking for but give a try.
    – tvl
    Commented Nov 3, 2014 at 15:42

2 Answers 2


As tvl advised, "import" path is not yet defined in when MYPROFILE_install() is called in MYPROFILE.install. So moved the code over to MYPROFILE.profile and used hook_install_tasks() as explained here: https://www.drupal.org/node/1022020

 * Implements hook_install_tasks().
function MYPROFILE_install_tasks($install_state) {
  $tasks['add_import_link'] = array(
    'display_name' => st('Adds import link to menu-administrator'),
    'display' => TRUE,
    'type' => 'normal',
    'function' => 'callback_add_import_link',

  return $tasks;

function callback_add_import_link() {
  // Add the menu link
  $link = array('menu_name' => 'menu-administrator', 'link_path' => 'import', 'link_title' => 'Import', 'weight' => 5);
  1. Enable the Feeds module in your my_installation.info file.

    dependencies[] = feeds
    dependencies[] = feeds_ui
    ; I also use:
    dependencies[] = feeds_xpathparser
    dependencies[] = feeds_tamper
    dependencies[] = feeds_tamper_ui
  2. Edit the my_ installation.profile and add there your menu link:

    function my_ installation_install_finished(&$install_state) {
      // Flush all caches to ensure that any full bootstraps during the installer
      // do not leave stale cached data, and that any content types or other items
      // registered by the installation profile are registered correctly.
      // Add the menu link
      $link = array('menu_name' => 'main-menu', 'link_path' => 'import', 'link_title' => 'Import');
      // This is not a correct - full install_finished(&$install_state).
      // Copy the Drupal's function and then edit it.

    Remember you must login to see the /import link.

  • Thanks for your response tvl... unfortunately this code did not work for me. I'll probably just go with putting it in a feature like you suggested above.
    – stevenkkim
    Commented Nov 3, 2014 at 23:27
  • @StevenKim there was a menu name mistake (is was my test menu). Did you change it? Is the install_finished() run properly?
    – tvl
    Commented Nov 4, 2014 at 16:07
  • Yes, I did. I copied the drupal install_finished function from here api.drupal.org/api/drupal/includes!install.core.inc/function/… into start.profile (my installation profile is called "start"). Then renamed the function start_install_finished, and then tried adding the link with the fixed menu name. No luck still. Thanks for trying to help me out though. I'll keep working at it, and if I find the solution, I'll post it here.
    – stevenkkim
    Commented Nov 4, 2014 at 21:00
  • I got it! Will post solution below. Thanks for helping me out tvl, you got me pointed in the right direction when you said that the menu item doesn't exit yet ... that was true. But I don't think Drupal lets you override install_finished. So instead, I used hook_install_tasks() as explained here: drupal.org/node/1022020
    – stevenkkim
    Commented Nov 4, 2014 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.