Table of Contents
- Backup your database
- Check my code out of Github, or create a module directory
- Create a project info YAML file
- Create the necessary subdirectories
- Write the code to display your block
- Clear the caches
- Enable the module
- Place the block module
- See the custom block on your website
- The biggest problem I encountered
- The source code
In this tutorial I’ll demonstrate how to write a simple Drupal 8 “block module.” By this I mean that I’ll show you how to write a simple Drupal 8 module that will display output in a block. When you’re done you will have created a new block that you can place in one or more theme regions.
A humbling thing about this MCAS disease is that I just took the time to make an, “If I’m dead, here’s everything you need to know about how to update this Drupal 8 website” video.
Hopefully I’ll still be around for Drupal 9 — or my own replacement for Drupal — but when I get sick I always wish I had done this, so now I have.
The URL I linked to is a story about how to convert a Drupal 8 website into a static website. What it comes down to is, if you’re just running a blog and you don’t care about comments, why bother dealing with all the ugliness of maintaining a Drupal 8 website?
As a note to self, I learned today that you can install Drupal 7 modules from the command line with this Drush command:
drush en module_name
drush en smtp
You can also update Drupal 7 modules with Drush. For instance, I just ran these commands on a Drupal 7 website:
drush up ctools drush up context drush up file_entity drush up media drush up rules
As a brief note to self, when you want to use the Drupal SMTP module with a Gmail SMTP server, such as for a Drupal contact form, the process goes something like this:
At some point I’ll get all of my Scala “date utilities” together in a single class (object, actually), but until then, here are a couple of date utility methods I wrote for my Scrupal6 project (a replacement for Drupal 6):
Dries Buytaert has a good story about how he created the now-defunct Mollom anti-spam service. No word on why they didn’t try to sell the service rather than just shut it down.