Sunday 6 December 2015

Using route_parameters in drupal 8 menu links

Just a reminder for anyone, how to create menu links in drupal 8 that point to the node/add/content_type page.

mymodule.add_whatever:
  title: 'Add whatever'
  description: 'Add whatever'
  route_name: node.add
  route_parameters: { node_type: 'name_of_node_type' }
  menu_name: main
  weight: 7

The code snippet above is from the mymodule.links.menu.yml file.