28 January, 2022 seen 660This is an article back from 2014, when I had the vision to launch a web agency in Tbilisi, Georgia. In the end, I didn…
On the project I'm working lately there is need for many not so simple solutions - one of them involves using Profile2 module, for creating a multi level user profile page - like there is one page for e-mail and password, then there is second profile page for personal information and more.
To handle this tasks, I'm using Profile2 module, what works 90% great - the rest 10% that doesn't works includes - it doesn't integrates well with Panels module - speaking of Panels - I literally avoid them as far as I can. Unfortunately I'm using Panels in this project - not much, but still.
I already faced a problem of displaying dynamic content in views- then I found an awesome solution - Menu Views.
Today I found another great module - Menu Tokens.
So back to the subject
So there is need to provide a menu for logged in users, with links to their profile pages.
Default Drupal menu - doesn't offer use of token, I mean you can use - user, user/logout.. if you will try to use user/edit - things will break up... so we need to insert a custom token in that menu - for example user/[uid]/edit (what actually is default path for user profiles)
But again - default Drupal menu - doesn't allow (offer) to use tokens - and there is need for another implementation.
I found a working solution - Menu Token
Menu Token module provides tokens, that could be used in title or in path of menu items (links). For example, if you create a menu item with path: "user/[current-user:uid]", the url will be changed "on fly" to: "user/1" (assuming you are user 1).
Tokens are provided by Token module. Menu Token allows to use both global tokens and entity ones: node, user, term, etc. Entity tokens have several methods of substitution: from context, random and user defined.
Menu token Resources
Menu token functionality can be extended gracefully. Following some examples:
- Menu token module implements Ctools plugin system and allows to plug in new token handlers.
- Use Extended path aliases to automatically translate paths like 'user/1/mycontent' to 'users/admin/mycontent'. Just need to create a 'root' path alias: 'users/admin'. See .
- Superfish integrates jQuery Superfish plugin with your Drupal menus. Use Superfish 1.9-beta5 or greater.
- Menu item visibility exposes configurable and extendable visibility settings for menu links. You'll need to set module weights so that Devel node access > Menu item visibility > Menu token.
- There are modules that use same hook as Menu Token, they need to be executed in proper order. For example: Menu per Role works well with a weight of 5.
- Some weird behavior happens when not using absolute paths, please help us solve it once and for all!
How I did setup a Menu tokens for me?
Menu link title
As you can see from screen above, after enabling menu tokens module you can use tokens in menu's.
Depending on complexity of your Drupal site - menu token can be a real time saver.
Though I haven't explored full potential of Menu Tokens module - I can admit - I'm glad it exists, and in one project I will use it for sure.