1

I am trying to create a menu link in Drupal 8. I am following this document: https://api.drupal.org/api/drupal/core!includes!menu.inc/group/menu/8

My module name is twitter_pull and I was able to create the path fine, and it loads a form on that page, I just can't get it display a menu link. I have tried flushing the caches but that didn't do anything. Here is my code:

Inside my twitter_pull.routing.yml

twitter_pull.settings:
  path: 'admin/config/services/twitter-settings'
  defaults:
    _form: '\Drupal\twitter_pull\Form\TwitterSettingsForm'
  requirements:
    _permission: 'administer site configuration'

Inside my twitter_pull.links.menu.yml

twitter_pull.settings:
  title: 'Twitter settings'
  description: 'Twitter settings for your site'
  parent: system.admin_config_services
  route_name: twitter_pull.settings
  weight: 100
  #Use menu_name when you want to add your link to a non-system menu.
  #menu_name: devel
3
  • I don't see any issues with the code and I added your snippets to the end of system.routing.yml and system.links.menu.yml respectively as a way to test and the menu link showed up fine after clearing caches.
    – star-szr
    Nov 7, 2014 at 14:57
  • I tried that and it worked too. I see now, that the menu links file in my system module folder is system.menu_links.yml. The docs I was looking at said the file name was module_name.links.menu.yml. I changed my file name to twitter_pull.menu_links.yml and it was picked up. Are the docs wrong or do I have an older version of D8? What version do you have? Nov 7, 2014 at 15:18
  • That was changed a few months ago. I'm on the latest 8.0.x checked out from git. Maybe you are on an alpha version? Here is the change record: drupal.org/node/2302893
    – star-szr
    Nov 7, 2014 at 16:36

2 Answers 2

2

It looks like you are using an older version of Drupal core. Upgrade to one of the betas or the latest 8.0.x from Git and it should work fine.

In the latest versions the filenames have been changed, as reported in YAML files for menu links, contextual links, local tasks, and local actions have been renamed. 8.0.0-alpha14 is the first tagged release with the filename change.

-2

Its because of incorrect file name issues. I also faced the same kind of issues and after analysis I got to know, I was did a minor mistake on the file name( 's' got added additionally ). Like: twitter_pulls.links.menu.yml instead twitter_pull.links.menu.yml

twitter_pull.links.menu.yml twitter_pulls.links.menu.yml

Thanks

Your Answer

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

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