0

I am new to drupal and currently using version 8. I am trying to convert cricket feed widget module in drupal 7 to drupal 8 based on Community instructions.. But I am unable to understand the routing.yml files. I don't understand the parameters used in the routing.yml file to connect with the controllers. I checked out some of their examples..

I don't understand

what they mean by sub_name and Path: Path to the page on site.How do I know that? Is it that much difficult to convert a simple drupal 7 module to drupal 8?

1
  • I might avoid rhetorical questions in the future even if you find something frustrating. You may also find the drush plugin, drupalmoduleupgrader to be helpful in understanding the differences from Drupal 7 code and Drupal 8 code. My best practice is to always review and change my code manually because I often like to change my approach depending on new APIs that are available. However that tool has an "analyze" mode which allows you to see what it's output would be, and this is excellent for reviewing and learning.
    – mradcliffe
    Jan 5 '17 at 14:15
3

I've spent the past few months doing a lot of D7 -> D8 upgrades. I haven't used sub_name (or even seen it), so I cannot comment on that, but as for the path, it's the same path you declared as the array key in your hook_menu definition - however note that with D8 you need to include the preceeding forward slash.

So if your D7 hook_menu() definition for a path was:

$menu['path/to/something']

In D8 your path in the routing file would be:

path: /path/to/something
1
  • sub_name in this example refers to giving the route an unique machine name (in addition to the best practice of prefixing the route name with the module name).
    – mradcliffe
    Jan 5 '17 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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