drupal

recent posts related to the drupal content management system

Drupal 8: How to write a simple custom “block module” alvin June 21, 2016 - 8:25pm
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.

How to update a Drupal 7 website with Drush (notes)

As a brief “note to self,” this is how I just updated a Drupal 7 website using Drush. Please note that the output of some of the commands below refer to early versions of Drupal 8, but these commands also work with Drupal 7.

First, do these things:

This website is a little one-man operation. If you found this information helpful, I’d appreciate it if you would share it.

Disabling Drupal 8 page caching significantly increases CPU use alvin April 22, 2018 - 2:53pm

As I noted five days ago, Mollom went out of business so I had to switch this Drupal 8 website to use a different module to control comment spam. I ended up adding two modules that work together, but the side effect of using their best features is that they end up disabling Drupal 8 page caching. This image clearly shows the result that disabling page caching has on CPU use.

Drupal 8 anti-spam modules, caching, and performance alvin April 17, 2018 - 7:39pm

I’m not sure why, but on April 3, 2018, the people behind the Mollom anti-spam module for Drupal basically went out of business. This meant that I either had to disable comments on this site (which I did for a while), or look at other anti-spam modules, which I did over the weekend.

How to test if Drupal 8 pages are being cached (and anti-spam modules) alvin April 14, 2018 - 8:09pm

As a brief note today, if you want to know if your Drupal 8 web pages are being cached, take a look at the headers that are returned by your Drupal 8 URLs. Here’s an example using the curl command:

Mollom is out of business

On April 3, 2018 this website suddenly got a ton of spam comments. Fortunately I caught the probably very quickly, and turned off the ability for people to post comments here. When I checked into the problem I found that Mollom — created by the same person who created Drupal — basically went out of business on April 2nd. (I’m sure there was some warning about this decision, but I sure didn’t get it.)

I’m often surprised when people who offer a free service shut down that service without asking a simple question: “Would you be willing to pay for this service, and if so, how much?”

(I’ll re-enable the ability to post comments here when I find a good replacement for Mollom.)

A Drush 9 list of commands (for Drupal 8) alvin March 27, 2018 - 3:22pm

I’m sure there’s something I’m missing here, but ... as I’m just getting started using Drush 9 to manage a Drupal 8 website, I can’t find a list of Drush 9 commands on the drush.org website. Therefore, in an effort to make my life easier (and hopefully yours), here’s a list of Drush 9 commands.

How to create a new book in Drupal 8 alvin August 2, 2017 - 2:44pm

To create a new book in Drupal 8:

How to write if/then/elseif/else in Drupal 8 Twig templates alvin August 1, 2017 - 5:35pm

As a quick note Drupal programming note, here’s an example of how to write if/then/elseif/else in Drupal 8 Twig templates:

{% if node.getType == 'photo' %}
...
{% elseif node.getType in ['book', 'page'] %}
...
{% else %}
...
{% endif %}

While I’m in the neighborhood, here are a few more if conditions I’ve written recently: