This is driving me crazy. For the life of me I can't seem to change the edit tab (user/%/edit) to a MENU_NORMAL_ITEM type.

What am I doing wrong? I figured all that needs to be done is...

function MYMODULE_menu_alter(&$items) {
$items['user/%user_category/edit']['type'] = MENU_NORMAL_ITEM;
}

Can anyone help me please and thank you.

Comments

jaypan’s picture

The user module may be a heavier weight than your module. You can check the weight of the user module in the systems table.

Contact me to contract me for D7 -> D10/11 migrations.

walker2238’s picture

Nope, that's not it. I can do already make other changes like the title and such.

jaypan’s picture

I don't have any suggestions beyond that unfortunately. It may be that Drupal won't allow you to change this particular item as it is fairly integral to the system. I have no idea though. What you are doing looks like it should work.

Contact me to contract me for D7 -> D10/11 migrations.

afreen.k’s picture

Try clearing the Performance Cache after you implement hook_menu_alter().

Hope it works !!!!

edemus’s picture

Have you rebuild your menu after changes ?
I hope you know in place of MYMODULE is name of your custom module right?

walker2238’s picture

Yeah I know, and I did. The problem I believe might be with the wildcards. Both "user/uid" and "user/uid/edit" uses different argument functions. I'd really be interested to see if someone has done this, because I searched both on here and google and found nothing.

walker2238’s picture

Ok, I'm starting to think that this isn't possible. Perhaps because other modules can add on to to edit menu, which may be the reason that "user/uid" and "user/uid/edit" use different wildcard functions?

As an alternative workaround would is be possible to alter the edit tab type to MENU_CALLBACK which would hide it but still keep the menu path and then some how create a new MENU_NORMAL_ITEM type.

Would this be possible considering I'd be using an already existing path?

jaypan’s picture

I have a feeling that if you couldn't change it to a normal item, you aren't going to be able to change it to a menu callback either.

Contact me to contract me for D7 -> D10/11 migrations.

walker2238’s picture

See that's the odd part. It does change. But when I change it to a normal menu item is vanishes so to speak. Pretty much the same as setting it to menu callback. As far as I understand by default the menu should appear in the main navigational menu.

walker2238’s picture

Any other thoughts or suggestions?

Chris Gillis’s picture

I'm trying to do something similar. I want to switch the tab order of my content profile tab. I want my users to see the content profile edit as soon as they click edit, then have the option to change their account.

function mysite_custom_menu_alter(&$items) {
  $items['user/%user_category/edit/application']['type'] = 136;//Set to default tab
  $items['user/%user_category/edit/account']['type'] = 128;//Set to secondary tab
}

(Numbers or constants, nothing seems to work)

As soon as I refresh my cache, tabs disappear completely.

I think your tab disappearing was not due to correctly being identified as MENU_CALLBACK, it disappears no matter what you change it to.

Chris Gillis’s picture

In fact, If I specify it to match the default (not changing anything) the tabs appear and work as expected.

function mysite_custom_menu_alter(&$items) {
  $items['user/%user_category/edit/application']['type'] = MENU_LOCAL_TASK;//Set to secondary tab
  $items['user/%user_category/edit/account']['type'] = MENU_DEFAULT_LOCAL_TASK;//Set to default tab
}

^This Works

As soon as I change it, the tabs disappear.

function mysite_custom_menu_alter(&$items) {
  $items['user/%user_category/edit/application']['type'] = MENU_DEFAULT_LOCAL_TASK;//Set to default tab
  $items['user/%user_category/edit/account']['type'] = MENU_LOCAL_TASK;//Set to secondary tab
}

^This Kills it

walker2238’s picture

The only solution I have found is to create a function to embed in the block template.

Chris Gillis’s picture

Hi Walker!

Perhaps you could share your code?

Cheers,
Chris

walker2238’s picture

Sorry Chris I have yet to write anything for this but it's a fairly simple idea. You have two options. The first option is at the theme layer. you can simply hard code the edit menu link in your block template. Keeping in mind you need to strip the ul tag and then add in yourself using strip_tags(). (Remember to allow the other markup such as li, a and so on).

The problem with this method is that the edit link can only appear as the first or last list item. And if you make use of the first of last classes then you'll have to add a new class for the edit link to enable you to style your menu as normal.

The second option would be to recreate your menu using a module. This option is a cleaner way to do things. So if you know how to create a module then do it this way using hook_menu().

I'm doing stupid home renovations so my time is limited and won't be doing this myself for another week or two. If you have any troubles feel free to ask. And if you don't need this right away I'll be sure to post a solution after the renovations are complete.

Also another less drupal friendly way is to create your own function like I said before and just put it in a block. Remember to use l() to construct your links.

mpompili’s picture

I've accomplished something similar doing a navigation link to the tab for the user profile page, not the regular drupal profile page but the one made with cck and content profile modules.

Here's is what i've done, first i've hidden the tab with the MENU_CALLBACK

<?php
function MY_MODULE_menu_alter(&$items){
  //Hide the tab and maintain the path
  $items['user/%user/profile/profile']['type'] = MENU_CALLBACK;
}
?>

Then i've created a menu item for the navigation menu with the two callbacks:

<?php
function  MY_MODULE_menu() {

  $items = array();

  $items['profile'] = array(
    'title' => 'My profile',
    'description' => 'You profile page',
    'page callback' => '_goto_my_profile_page',
    'access callback' => '_goto_my_profile_access',
    'type' => MENU_NORMAL_ITEM,
  );
  
  return $items;
}

//Just check if the user is logged assuming that the uid = 0 is anonymous
function _goto_my_profile_access(){
  global $user;
  return ( $user->uid != 0 );
}

//Redirect to the tab page
function _goto_my_profile_page(){
  global $user;
  drupal_goto('user/'.$user->uid.'/profile/profile');
}
?>

I use a drupal_goto to access the tab profile page not in the cleanest way maybe. I guess you can use drupal_goto directly on the page callback but i still have problems passing arguments to the page callback... well go easy on me I'm still quite a noob with Drupal :P