Under construction.
Creating contextual menu items
Menu Token module allows to insert tokens into menu items title and path.
We are going to create a list of all articles published by the authenticated user using the Menu Token and Views modules.
- Create a view with context arguments.
- Create a dynamic menu item
Go to Structure > Views and create a new view named "User Articles" that show "Content" of type "Article" and has the path "/articles".
Then we need to configure the view to shows the node title and body summary.
Also we need a Relationship with the author of the article to be used in the contextual filter.
The key configuration step is add a Contextual Filter for the user name. With this filter we can filter the node author.
When the filter is not specified in the URL the view doesn't the shows any result.
Then check the “Override title” option and use the first argument to override the title with “%1's Articles”. Change the “Case” option inside the “More” field set to Capitalize first letter.
Go to Structure > Menu, create a new menu and add new link. Check the option “Uses menu token”. Open the node Current User and pick the current-user:id options. Now that option you selected is in the path field.
Attachment | Size |
---|---|
menu-token-create-view.png | 31.89 KB |
menu-token-view-config.png | 67.24 KB |
menu-token-view-relationship.png | 20.78 KB |
menu-token-view-contextual-filter.png | 15.21 KB |
menu-token-view-filter-no-reresults.png | 19.47 KB |
menu-token-view-override-title.png | 25.74 KB |
Comments
I followed step by step but
I followed step by step but nothing happens, the menu link does not show up.
Last step is a bit unclear.
Check the option “Uses menu token”. Open the node Current User and pick the current-user:id options. Now that option you selected is in the path field.
So in path you only put current.user:id ?
Options: Method for Nodes and Method for Users should be left as default (disabled) ?
Method for Users
In the example above, Method for Users should be set to "User from context." Here's a blog post that basically follows the above example and also includes an example using "Current Node Type."
It dont work for me!
I do all steps.
If I put in the path: user/[current-user: mail] or anything else, the menu item always directed to q=user.
I'm going crazy!