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?
1 Answer
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 Jan 18, 2013 at 18:42
-
You can pass
plid
as the parent link ID in your$item
, so save 'Events' first, then saveAdd Events
with aplid
of the first item'smlid
(menu link id, it's returned frommenu_link_save()
)– Clive ♦Jan 18, 2013 at 18:46