Advertising sustains the DA. Ads are hidden for members. Join today

Dynamic menu elements with tokens

Last updated on
30 April 2025

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.

  1. Create a view with context arguments.
  2. Go to Structure > Views and create a new view named "User Articles" that show "Content" of type "Article" and has the path "/articles".

    Create user articles view

    Then we need to configure the view to shows the node title and body summary.

    Users Article Fields

    Also we need a Relationship with the author of the article to be used in the contextual filter.

    User Article auhor relationship

    The key configuration step is add a Contextual Filter for the user name. With this filter we can filter the node author.

    User article contextual filter

    When the filter is not specified in the URL the view doesn't the shows any result.

    User article contextual filter no results

    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.

    User article contextual filter override title

  3. Create a dynamic menu item
  4. 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.

Help improve this page

Page status: Not set

You can: