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.
Funny, and sad.
From the link: “Many people who work in software development today have heard of the practice of pair programming, yet it still only has patchy adoption in the industry. One reason for its varying acceptance is that its benefits are not immediately obvious, it pays off more in the medium- and long-term. And it's also not as simple as ‘two people working at a single computer’, so many dismiss it quickly when it feels uncomfortable. However, in our experience, pair programming is vital for collaborative teamwork and high quality software.”
November 29, 2019: A few days ago I made the PDF version of “Hello, Scala” free, and today I made the paperback version of “Hello, Scala” available again, and reduced it’s price from $20 to just $10. Click the image below to buy the book on Amazon.
As I’ve noted before, the contents of this book are being updated and improved, and in the future it will be available as Scala Book. The HTML version of those contents are currently available on the docs.scala-lang.org site.
“To be a programmer is to develop a carefully managed relationship with error. There’s no getting around it. You either make your accommodations with failure, or the work will become intolerable.”
~ Ellen Ullman (via this tweet)
This quote makes me think of all those years of exception-handling with Java. I never knew there was a better way to handle errors, so I developed a strategy of letting my exceptions bubble up to the controller level (as in model/view/controller), where I would deal with them. These days I know I can use Option/Some/None in Scala, as well as Try/Success/Failure.
“Treat your code like poetry and take it to the edge of the bare minimum.”
“I have learned magnitudes more from code I have maintained over code I have written from scratch.”
~ Viktor Klang, in this tweet
I have no idea who or what ILYO is, but I like the “poetry” part, and dislike the “bare minimum” part. As the second quote implies, code should be written so you can read it a year or two from now.
Programming is an interesting profession. You fail dozens or hundreds of times a day, then take a moment to celebrate a little victory. Then you move on to your next failure/success.