0

I need a menu item living in the user-menu, has path like 'user/%something' but i dont want it to have "My account" link as parent (that has path 'user')

i can only change that through the administration but this is not an accepted answer...

Any thoughts?

thnx

0

Even though the documentation of hook_menu() doesn't mention it, the plid attribute can be used for specifying the ID of the parent menu link. You can set it to 0 if you don't want your menu item to have a parent.

It's probably not included in the documentation, because it's problematic to know the menu link ID (mlid) on that level where you use hook_menu(). It's an incremental identifier in the database, so there is no guarantee that it will always be the same (e.g. after reinstalling the site if you work on an installation profile). So I don't think it's a good idea to make a use of this attribute, except of course when you have this simple use case that setting it to zero does the job.

1

pff got it

had to

hook_menu_link_alter

and changes this link's plid like:

/**
* Implements hook_menu_link_alter().
*/
function YOURMODULE_menu_link_alter(&$item) {
  if ($item['link_path'] == 'user/some-path') {
    $item['plid'] = '0'; // instead of '2' (My Account menu item)
 }
}

drupal is a pain sometimes... but we love it anyway

  • Are you creating the menu item in hook_menu()? Because then you can specify the plid there. – balintk Feb 6 '13 at 14:41
  • How? there is no such option in hook_menu() – Pan Chrono Feb 6 '13 at 15:05
  • I believe you can do it in the same way as you did in your hook_menu_link_alter() implementation. Just use the plid key, give it a try! ;) – balintk Feb 6 '13 at 15:09
  • you are absolutely right , its the same array after all ...., why dont you make it an answer? – Pan Chrono Feb 6 '13 at 15:13

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.