2

I'm trying to build an intall profile that implements a number if features. I am running into some issues because although features allows me to require menus, it seems there is no way to also include the links (most of the link are simple aliases to add content or edit views). Is there a way to add menu items from within the install profile?

5

You can follow the example from the profiles/standard/standard.install file and use code like this inside your implementation of hook_install():

// Create a Home link in the main menu.
$item = array(
  'link_title' => st('Home'),
  'link_path' => '<front>',
  'menu_name' => 'main-menu',
);
menu_link_save($item);
  • Thanks! what if the menu is hierarchical, for instance I have a menu the has an events link, and under the events link is an add events link – user379468 Jan 18 '13 at 18:42
  • You can pass plid as the parent link ID in your $item, so save 'Events' first, then save Add Events with a plid of the first item's mlid (menu link id, it's returned from menu_link_save()) – Clive Jan 18 '13 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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