My client wants a menu with a link for each content type.

  • Each item will displayed if the user have permission to create that content type.
  • Each item will show a list of content only for that content type.

To accomplish this, I create a view page that have a filter for bundle. In that way I can use same view page for all content types. I tried too, to use same view page like /admin/content but I need to pass the content type to filter for that machine name.

What I trying to do, is create a menu item for each content type, and set permission for each item(link) using the permission that have each content type.

E.g.: My menu have a Item Article. You should see this item only If you have right to create an Article. When you click here you will see all the content Articles(like /admin/content).

It suppose that a user or role, that have permission to create a content type.. should see the item.

How can I create menu items with permission to a view?

There is my issue, because it use the permission in the view page, and not in the route.

enter image description here


 title: 'Articles'
 parent: content_types.admin_menu
 route_name: content_types.admin_1
  type: article
 description: 'Content articles'

 title: 'News'
 parent: content_types.admin_menu
 route_name: content_types.admin_2
  type: nouvelle
 description: 'Content news'


  path: '/admin/view-test'
    _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
    _title: 'Articles'
    _permission: 'create article content'

  path: '/admin/view-test'
    _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
    _title: 'News'
    _permission: 'create nouvelle content'

As you see I added _permission: 'create article content' but it didn't do anything.


enter image description here

The role for the user that I'm using doesn't have permission to create article or news.


I created a .permissions.yml and used _permission: 'access menu item 1' but it display the item even if this permission is not ticket for that role.


'access menu item 1':
  title: Access Menu MTL 1
  description: Allow users to access menu MTL

Any suggestion?

UPDATED: January, 2019

The issue is try to use same view page(/admin/content) for each Content type with different permissions. You dont set permissions to each link, instead you set permission to the view (or item) that you are trying to access.

  • Have you defined your permissions in a .permissions.yml file? Please see kevinquillen.com/drupal/2016/02/21/… Sep 14, 2018 at 19:36
  • not, I think those permissions are created when content type are created, or not?
    – Carlos
    Sep 14, 2018 at 19:38
  • No, the ones you're using are not defined. You can check in the permissions page for the correct names created by Node module Sep 14, 2018 at 19:40
  • I see this : 'Article: Create new content' but .. when I export the config for that role.. it add this 'create article content'
    – Carlos
    Sep 14, 2018 at 19:50
  • The entire solution appears a little hackish. Dynamic menu items might help. But maybe I'm just missing your point. For a good answer, it would be of help for you to add some further information about what your overall goals are, and why you use a view instead of menus/local tasks. Sep 14, 2018 at 23:00

1 Answer 1


What I did:

I tried using dynamic menus. But it isn't functional for my purpose. Because, each link menu could have different access by roles.

Then I realized that I needed to create a view for each type of content to be able to manage an individual permission.

Therefore I need to create a view each time that I create a CT, so the is no sense to do it dynamically.

How I did:

  1. I create a view for each CT with a filter content by type. And also I set permission for each view for same CT. And a custom route. enter image description here

  2. Create one item menu for each CT and set as route same as is in the view.


     title: 'Sujets'
     parent: system.admin_content
     route_name: vdm.tc_sujets
     description: "Content type subject."
     weight: -1


     path: '/admin/content/sujet'
       _controller: '\Drupal\system\Controller\SystemController::systemAdminMenuBlockPage'
       _title: 'Sujets'
  1. As result if user have access to that view the item menu will be displayed.

enter image description here

Note: I think that dynamic menus it fix great for add link item to nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.