User login

Adding action links to pages in Drupal 8

To add an action link for creating content of a given node type on a related listing view, you could add to 'example' module an example.links.action.yml file with contents like the following:

  route_name: 'node.add'
    node_type: 'resource'
  title: 'Add resource'
    - view.search_resources_content.page_1

drupal 8 action links on dynamic routes
links.action.yml appears_on dynamic

To put an action link on an arbitrary node page, you'll need to get the route for that node. You can't do drupal router:debug | grep '/my-alias' nor even drupal router:debug | grep '/node/8' — console is only providing the real routes, not the (literally infinite) paths that can be created by these routes.

If you do:

drupal router:debug | grep '/node/'

You'll note it returns the route:




You cannot use a yaml file to put an action link on a dynamic path, on a route name only when given a parameter, such as a particular node.


How do I create a link to add a specific content type

Create an "add content" link in View Header that is only visible to users with appropriate permissions. [Solved]

Add link to add content to views lists

Add action link to view

See also:

Local action links now provided by plugins using YAML discovery and implementing LocalActionInterface

YAML files for menu links, contextual links, local tasks, and local actions have been renamed!core!modules!block_content!block_content.links.action.yml/8

c: 2016 November 21, Monday, 5:27 PM

Searched words: 
drupal 8 add action link drupal 8 add add content link drupal 8 local task add Drupal 8 see route providing path drupal 8 node id as route parameter yaml what are the route names for node add in Drupal 8 Drupal 8 see route providing path


Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.