Create local task links

I wanted to add some views as tabs the user can access in their account. They list the user's content and comments.

user tabs

First, I cloned the content and comments views to create my_content and my_comments. These have the urls 'user/%user/content/my-content' and 'user/%user/content/my-comments'.

I create a module user_tabs with the file user_tabs.links.task.yml:

user_tabs.content:
  route_name: view.my_content.page_1
  title: 'Content'
  base_route: entity.user.canonical
  weight: 4

user_tabs.user_content:
  route_name: view.my_content.page_1
  title: 'My content'
  parent_id: user_tabs.content
  weight: 0

user_tabs.user_comments:
  route_name: view.my_comments.page_published
  title: 'My comments'
  parent_id: user_tabs.content
  weight: 1

 

The route_name for a view is view.VIEW_NAME.DISPLAY_NAME. If you create a view events, the default route is view.events.page_1.