Hi.

I am currently doing my first website with Drupal. I think I have figured the platform pretty well, and was able to do most things I wanted to do.

I have a problem though: I need to put the 'My account' menu items (from the navigation menu block), into another menu.

This is the menu I have:

- Meeting place
  - My profile <=== this is where i want the 'My account' menu item
  - Another section
  - Another section 2

I was able to make move it to this place, by hardcoding "user/1" in the menu path of this item, and by logging as the admin. Worked pretty well. The 'my account' menu item was even taken off the 'Navigation' block menu. But it doesn't work when Im logged in with other users.

I've searched the website, only to find a similar problem, but it dates back to January, on another version, and the item ended up being locked in the admin section.

Any ideas how I could achieve this ? Is there any way I can put a tag reffering to the userID in the menu path?

I really need this to work...

Thanks, all

flemieux--

Comments

flemieux’s picture

I'm sure a tweak or something exists for this :)

--flemieux--

behindthepage’s picture

If you put this script in a custom block it will display a link to the current users "my account"

print <<< HERE
<div class="menu">\n<ul>\n
<li class="leaf"><a href="/?q=user/$user->uid">My Profile</a></li>\n
</ul>\n</div>
HERE;

If you want it to go to the edit page first use this link

<a href="/?q=user/$user->uid/edit">My Profile</a>

Then to get the rest of the menu happening below it read this:

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://your.domain.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);
print $sna['content'];
?>

Replace the number "85" with your menu number and drupal will generate that menu in that block. Make sure you enable the block in admin/block.

gpdinoz

"If we see further it is because we are standing on the shoulders of giants"

Regards
Geoff

scoonz’s picture

What about using this:

print <<< HERE
<div class="menu">\n<ul>\n
<li class="leaf"><a href="/?q=user/$user->uid">My Profile</a></li>\n
</ul>\n</div>
HERE;

Don't forget to include

global $user;

before print, else the code will not work.

Music demos online

greg.harvey’s picture

The actual "how to" for this contains a better example, using the l() function for the links:
http://drupal.org/node/54511

I have also posted code at the bottom in the comments regarding retrieving menu items before they get placed in ul tags. Hope that helps someone.

UserFriendly’s picture

I was able to make move it to this place, by hardcoding "user/1" in the menu path of this item, and by logging as the admin. Worked pretty well. The 'my account' menu item was even taken off the 'Navigation' block menu. But it doesn't work when Im logged in with other users.

If hardcoding "user/1" worked, but only for the admin account, would hardcoding just "user" achieve the desired effect? As far as I'm aware, navigating to www.example.com/user loads the current user's profile or the login page.

-UserFriendly

scoonz’s picture

example.com/user does NOT lead to user's profile, but to users list. You should use example.com/user/profile (or any other user/blahblah path) instead - this will redirect you to the url with correct used_id at the end of it. Profile module should be enabled of course.

Building bands and music communities sites, thanks to Drupal !
Music demo studio

scoonz’s picture

I've created handbook page for this subject:
http://drupal.org/node/54511

--
Building bands and music communities sites, thanks to Drupal !
Music demos online

Dixen’s picture

I'm using Drupal v4.7 and I just used "user/" as a new menu item and it does in fact go to the appropriate user's profile... This was confirmed with my administrative account as well as a test account... no users are reporting any problems with the new link either.

mfb’s picture

In 4.7, what I did was add "user" as a menu item in my new custom menu. This caused the locked "my account" (user/uid) menu item to magically show up as a child menu item. Then I disabled the "user" menu item. The locked "my account" menu item stayed behind where I wanted it in my new menu.

megg’s picture

this ^^ worked for me as well with 5.2, but i didn't have to disable the "user" menu item. i set it to "expanded" and the original "my account" item magically disappeared!