programming

Drupal 8: How to write a simple custom “block module”

Table of Contents1 - Goals2 - Backup your database3 - Check my code out of Github, or create a module directory4 - Create a project info YAML file5 - Create the necessary subdirectories6 - Write the code to display your block7 - Clear the caches8 - Enable the module9 - Place the block module10 - See the custom block on your website11 - The biggest problem I encountered12 - The source code13 - Summary

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.

An intense curiosity about how things are done

In his book, The Universal Tone: Bringing My Story to Light, Carlos Santana writes about hearing other guitar players, and wondering with an intense curiosity how those other people got their guitars to make the sounds they made. As I thought about this I thought it was a good attitude to have in programming. For instance, if I look at an application where someone has done something really cool I try to understand, “How did they do that?”

The most important principle for the algorithm designer is to refuse to be content alvin January 20, 2017 - 2:35pm

“Perhaps the most important principle for the good algorithm designer is to refuse to be content.”

~ Alfred Aho

Rubber Duck Debugging alvin January 17, 2017 - 2:56pm

I was just reminded of Rubber Duck Debugging. From this Wikipedia link, “The name is a reference to a story in the book The Pragmatic Programmer in which a programmer would carry around a rubber duck and debug their code by forcing themselves to explain it, line-by-line, to the duck.” For me, my rubber duck is Albert Einstein.

Vital assets of competent programmers (Edsger Dijkstra) alvin January 14, 2017 - 9:46am

“Besides a mathematical inclination, an exceptionally good mastery of one’s native tongue is the most vital asset of a competent programmer.”

~ Edsger Dijkstra

Dan Bricklin: The history of VisiCalc and other things alvin January 4, 2017 - 6:22am

Dan Bricklin, inventor/creator of VisiCalc, the first spreadsheet program for personal computers, has created this page of historical notes and images about his work. His work came long before my interest in computers and programming, so I enjoy reading about it from a historical perspective. He shows a TI calculator and very large state diagram on this page. I remember seeing calculators like that in stores, and the work he put into the state diagram looks like a modern mind map.

If you’re into history, it’s all very cool.

“I fear things unless I understand them” alvin December 3, 2016 - 9:26am

“Years ago I knew little, but was comfortable using things I didn’t understand. Now I’m experienced, I fear things unless I understand them.”

~ A good quote from Jon Pretty

Software best practice: Never say “X% done”

Note: This is a post from 2007 that I just updated a little bit because I think there’s still some value in it.

A lot of people have written to say that it’s unfair that I think developers should never say “I’m 75% done,” or “I’m 90% done.”

So, to explain myself, here’s why I think you should never use a phrase like that: