Well i've tried the following code to insert an attribute to the user-account link on installation profile.It works for all other menu items (Home[]), except the user-account link, probably due to the reason it is rebuilt again.
<?php $path = 'user'; // Check for user (My account) menu item. $existing_item = db_select('menu_links') ->fields('menu_links') ->condition('link_path', $path) //->condition('module', 'system') ->execute()->fetchAssoc(); $item = array( 'mlid' => $existing['mlid'], 'link_path' => $existing['link_path'], 'link_title' => $existing['link_title'], //'menu_name' => $existing['menu_name'], 'router_path' => $existing['router_path'], //'module' => $existing['module'], //'plid' => $existing['plid'], 'options' => array( 'attributes' => array( 'target' => '_blank', ), ), ); // $item['options'] = serialize($item['options']); // $item = _menu_link_build($item); // $link['options'] = serialize($link['options']); if (menu_link_save($item, $existing) == $existing['mlid']) { drupal_set_message(t('User menu target attribute updated')); } The above code :
- selects form the database the {menu_links} record for 'user' menu item.
- Alter the options in the $item['options'] array
- Performs menu_link_save() on the existing item since we have given an existing $mlid
Well, i've tried menu_cache_clear, rebuilds, straight altering the database values.. everything! but the "My account" link is rebuilded after my profile installation routines, even though is the last one.
How this will work? How can i achieve this kind of alteration in installation profile?
In general, is it possible to override module-defined menu items options/properties in profile, or hook_menu() will run always after my code and revoke all my changes?