recent posts related to the drupal content management system

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.

Notes on how to update a Drupal 8 website

As a quick note to self, I just updated this Drupal website in less than three minutes. Actually, what I did was (a) test the Drupal update on a Test server, and then (b) did the update here in less than three minutes.

The following block shows my Cliffnotes on performing the update. If you’re familiar with Drupal, these notes may make sense, and help you when you need to perform an update of your own.

Help, my Drupal 8 database is huge

Earlier today I ran into a problem making a Drupal 8 database backup. I ran the usual mysqldump backup command, and when it kept running for a long time I decided to kill it, and then began investigating the problem. I knew that I had recently deleted all of the log records, and the Drupal cron task was running correctly, so something else was going on. In short, I found that my Drupal 8 database was huge.

New version of this website

If you’re reading this, that means the DNS change for alvinalexander.com has propagated to your location. I just moved this website to a new server and the latest version of Drupal on June 18, 2016. If anything is wrong with it, well, that’s gonna be my fault. I’ll fix broken things as fast as I can. :)

Drupal - Jump for joy, or off the balcony

Drupal alternatively makes me want to either jump for joy or jump off the balcony. Today was a balcony day.

Today’s issue is related to the handling of “tags” in Drupal 8, specifically the issue where you can’t add a new tag when editing a blog post, you can only reference existing tags. I have a degree in aerospace engineering, founded and sold a programming business, and can write software in many different languages, but a few things like this in Drupal make me feel like I need more of an education.

Drupal “Rewrite the output of this field” replacement patterns

As a quick note, if you’re looking at a Drupal form and it says you can use the "Rewrite the output of this field" replacement patterns shown (somewhere) on this page — and you can’t find those replacement patterns on that page — you can find a complete list of them at this drupal.org url.

As an example, if you’re working with a Drupal Node, you can use replacement patterns like these:


A Drupal 8 XML Sitemap generating PHP script

I’m not going to comment on the following code too much or provide support for it, but (a) if you need to create an XML Sitemap for a Drupal 8 website, and (b) you don’t like the Drupal 8 sitemap modules that are available, then (c) this PHP script can serve as a starting point for you.