How to use tokens in menus?

Events happening in the community are now at Drupal community events on www.drupal.org.
DrupalCuckoo's picture

hi,

how can I use tokens like "%user" when creating menu elements at "/admin/build/menu-customize/navigation/add"?

What I try to do is this:

  • At "admin/build/menu/add" I created a new menu called "Top Navigation" (top-navigation).
  • This menu should contain links to user profile pages, like:
    -- Profile Homepage -> user/[USERNAME]
    -- Edit your profile -> user/[UID]/edit
    -- List your friends -> user/[UID]/friends
    -- List your content -> user/[UID]/content
    -- etc.

As you can see, each link contains at least one token. But when I try to create links with tokens at "admin/build/menu-customize/menu-top-navigation/add" it won't work (i.e. "user/%user" as path to the profile homepage). I searched at groups.drupal.org and the whole freakin internet but I can't find a way to do that :-(. I also tried to write a module by using hook_menu() and hook_menu_link_alter() but this didn't work out as I thought it would. I wasn't able to create a link pointing to "user/%user" and putting this link into the menu block "Top Navigation".

How can I solve this?

Thanks for any help.

best regards.

Comments

quick reply :

Hi Arshad, thanks for your

DrupalCuckoo's picture

Hi Arshad,

thanks for your answer. I'll try this out :-)

Is there a way to write a module which creates a menu-block with "hook_menu()" and then put this menu-block into a region (either also through the module or by going to "/admin/build/block")?

The menu structure I'm thinking of is something similar to this:

  • My Profile (the user profile -> "user/[USERNAME]" but redesigned via panels.module)
    -- My Friends (a page at "user/[UID]/friends" created via panels.module)
    -- My Content (a page at "user/[UID]/content" created via panels.module)
    -- Edit Account Information (the default user edit page -> "user/[UID]/edit")
    -- Edit Profile Information (link to the edit page of a profile node created via content_profile.module -> user/[UID]/edit/profile)
    -- etc. (whatever I want to link to)

Maybe you have an answer for this, too :).

Thanks for your help.

best regards.

I tried the me.module and

DrupalCuckoo's picture

I tried the me.module and immediately after installing and opening the page "admin/build/menu/item/342/edit" I got this warning message:

warning: Missing argument 2 for user_category_load() in /var/www/drupal/modules/user/user.module on line 1160.
warning: Missing argument 3 for user_category_load() in /var/www/drupal/modules/user/user.module on line 1160.

I also found this issue: http://drupal.org/node/803702

I'm using the latest drupal version 6.17.

Any idea what's going on?

I'm using the Menu Token

tbartels's picture

I'm using the Menu Token module to do exactly this: http://drupal.org/project/menu_token

Social Networking Sites

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: