There are some Navigation menu items that you can neither move nor rename (e.g. 'my account', 'my blog'). These items contain user id number in their paths (e.g. user/26), which creates difficulties assigning such paths to "normal" menu items. This snippet will help you to create your custom block that contains "locked" items along with some "normal" menu items.

If you want your menu to contain only 'my account' and no more "locked" items (and may be some "normal" items), you can use the simplest method:
just create your custom menu and add 'my account' item with path user/profile (or user/ANYTHING_EXCEPT_NUMBER). This url will redirect user to 'user/xx' where xx - is correct user id.
This method works only for 'my account' !

If you want to add some other "locked" items, please do the following:
Create custom block and put there the following code (enabling PHP input)

<?php
global $user;
echo '
<ul class="menu">
<li class="leaf">'.l('My account', "user/$user->uid", array('title' => 'My personal info')).'</li>
<li class="leaf">'.l('Edit my info', "user/$user->uid/edit", array('title' => 'Edit my personal info')).'</li>
<!--any other locked or normal items here-->
</ul>';
?>

Make sure you enable the block in admin/block.
This way you can insert any other "locked" or "normal" items to the menu. But for appending "normal" items there is an easier way (thanks to gpdinoz) - see below. Though his method has a disadvantage that ALL "normal" items will come after (or before) the "locked" and cannot be mixed. If you want them to be mixed - insert them into the block code above.
Here is the method:

Create a menu for the rest of the items ("normal").
Once a menu has been created you will see "edit" and "delete" below it's title in admin/menu. When you hover the cursor over them you will see something like this in the status bar of your browser

http://example.com/?q=admin/menu/item/edit/85.

This last number (85) is drupals reference number for that menu and will be used in the following code.

Add the following code below the other bit

<?php
$sna = module_invoke('menu', 'block', 'view', 85);
echo $sna['content'];
?> 

Replace the number "85" with your menu number and drupal will generate that menu in that block.
That's all !

Comments

ccarlton’s picture

This worked for creating a new My Account link... as in it didn't MOVE, it COPIED to the new block..

How does one actually MOVE it though? I.e. Removing it from the default Navigation Menu?

Also, the second snippet generates it's own UL tag, so finicky people who want their menu's to line up with the same amount of vertical spacing may have a problem with that method.

If you are interested in making a "Personal" menu of mostly 'locked' type items, the best way to accomplish this IMO, is to make a new "Main" (non personal) menu, and put all the normal items there, leaving the locked items (plus logout probably), in the original menu.

publicme’s picture

Your method "... just create your custom menu and add 'my account' item with path user/profile..." works, but it does not solve my related problem.

First, instead of using the default "User login" scheme, I use a custom menu with only these links:

'Log in'
'Create new account'
'Lost password'

So, visitors don't see the 'User login' form fields. Anonymous visitors can link to the respective forms and log in, create account, or, lost password.

Your method above adds an additional block 'Navigation' with a 'My Account' link below my custom menu for anonymous users, which I don't want.

Now, after logging in, I want "My Account" to appear under the user's menu. But I have this disabled in the Navigation menu, as I don't want it to appear per the above description, so it fails to appear. (Wherever the user goes, I want a 'My Account' link to appear under the user menu.)

When I put a 'Log in' link in my custom menu, I noticed that the locked '- My Account' item automatically jumps from the 'Navigation' menu area to my 'Site Access' menu. Alternately, when I go back to the 'Navigation' menu and enable 'Log in', '- My Account' automatically jumps back from my custom menu to the 'Navigation' menu.

How do I use a custom menu with 'Log in' without having 'My Account' appear in an unncessary 'Navigation' menu below, and then, once logged in, the user see's My Account under their user menu on every page? Confusing! Yes, I'm confused. But I can't think of a clearer way to explain this.

I thought of using the Login Destination module to simply redirect users to their 'Account settings' page, which is an area I'd like to make more available, however, as the user browses the site, the My Account link still wouldn't be available, so my problem remains unsolved.

Prodigy’s picture

It should be noted that the easiest way to do this is to create a new menu, and add a new menu item to your newly created menu with the path "user". It will automatically move the menu for you.

greg.harvey’s picture

No one else seems to have mentioned this, so I will:

When using the module_invoke approach detailed above, the output is a themed, finished menu. This may well not be desirable, as you may want to prepend or append your menu items to the menu - like this you will have to style out the gap between the two menus, which is a cludge.

So, if you want to get the themed items, but not already buried in unordered list tags, use something like this code, which I tracked down by working through the menu module and menu.inc:

global $user;

print '<ul class="menu">'.
'<li class="leaf">'.l('Edit my account', "user/$user->uid/edit", array('title' => 'Edit my account')).'</li>'.
'<li class="expanded">'.l('My profile', "user/'.$user->uid", array('title' => 'My profile')).'</li>'.
// menu_tree($pid) returns the actual themed bullets
menu_tree(85).
'</ul>';
HorsePunchKid’s picture

Grab the path redirect module. Create a redirect from custom-menu-name to user. Add a menu item with the path custom-menu-name and whatever title you'd like. The menu item will show up and function just fine, and clicking it will redirect you to user, which will in turn redirect you to your own user page. Voilà!

-- Steven N. Severinghaus <sns@severinghaus.org>

airali’s picture

the "my account" link works only changing the path in user, NOT user/profile