I've been checking the examples for creating a custom module in Drupal 8 and found the code for the custom page module.

I was wondering if there is something similar but for modules that render custom blocks.

What I want to create is a custom module that makes a GET request to an API and prints the results in a custom block.

Any pointers will be appreciated.

  • The official docs are pretty straightforward on building a custom block in code as well as a module. What have you tried?
    – Kevin
    Commented Apr 11, 2018 at 19:14
  • For the record, those official docs live here: drupal.org/docs/8/creating-custom-modules/create-a-custom-block. If it didn't work, or you got stuck, please ask more specific questions. Commented Apr 11, 2018 at 19:44
  • Thanks for the info! Got confused on some of the concepts on the full page. Will check them out. Appreciate it. Commented Apr 11, 2018 at 23:14
  • You may also consider using Drupal console to generate the block custom code - it creates a great boilerplate you can customise. drupal generate:module if you need to create a custom module & then drupal generate:plugin:block for the block.
    – 100pic
    Commented Apr 11, 2018 at 23:58


Your Answer

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

Browse other questions tagged or ask your own question.