Articles

Drupal 11: How To Alter Entity View Builder Configuration Before Rendering

I encountered an issue on a Drupal 11 site recently where I had a block that was rendering an entity to display on a page.

There was nothing unusual about what was going on in the rendering process, but in this case I needed to add some attributes to the entity markup and I found that this process wasn't that simple. The solution was to intercept the rendering process half way through using a pre-rendering callback method.

As it wasn't that simple I took some notes and decided to convert them into an article to show how to do the same. In this article we will look at using the view builder to generate a renderable view of an entity and then look at how to alter the attributes of the view mode without using a preprocess hook.

DrupalCamp Scotland 2025

This year, DrupalCamp Scotland was held on the 7th November, at the University of Edinburgh.

On the morning of the conference I made the quick walk from by bed and breakfast and arrived at 50 George Square to join in with around 60 attendees to a day of talks and chatting.

The morning coffee and a selection of pastries was set out in the corridor outside the main room of the conference. I'm sure a few of the tasty pastries were lost to passing students.

After getting settled in we had a quick introduction session by Stratos Filalthis before we started the day.

Drupal 11: Programmatically Change A Layout Paragraphs Layout

The Layout Paragraphs module is a great way of combining the flexibility of the layout system with the content component sytem of the Paragraphs module. Using this module you can set up a Paragraph that can understand different layouts and then inject Paragraphs into that layout, all within the confines of a single field.

What this means is that you users can build the layout they want within the edit pages of your Drupal site, without having to guess where Paragraphs will end up in the final site. It makes the site a little easier to edit and means that there should be less previewing of pages before publishing.

When working on a recent project I found that layout Paragraphs was in use, which wasn't a problem. The problem was that the site was quite simple, but had 12 different layouts to pick from. As a consequence, the pages consisted of a variety of different layouts that not only made the site difficult to edit, but also made the end result look a little messy.

A Look At HTMX With PHP

HTMX is a JavaScript library that can be used to issue AJAX requests, create CSS transisions, and set up web sockets using HTML

The power of HTMX is that it can be used without writing any custom JavaScript code. It works by looking for attributes in HTML tags using that information to set up events, user interaction, and send requests to a back end. The system is backend agnostic and so will essentially work with any system that can accept, interpret, and respond to the requests.

I have been meaning to look at HTMX since hearing about as it seemed like a decent system with a good community. Since then it has been included into Drupal 11.2.0 and there are plans to make it the core system for AJAX requests going forward. As a result it has jumped forward in my list of things to look at.

Drupal 11: Using SDC Component Library To Preview Single Directory Components

Single Directory Components (SDC) consist of a directory of files that go together to create a small component on a Drupal website. SDC can be nested together, which means that a consistent set of elements can be created and plugged together on a site.

The power of SDC comes from their ability to be self contained. If you have the need to build a complex component that displays data in a widget then building it as a SDC means that you can ensure that every time you include it, the same widget will be shown.

It is possible to add an SDC to your Drupal site without adding them into tempaltes first. You can use the SDC Component Library module to preview them whilst you are building them, and then integrate them into your site once they are ready.

Drupal 11: Using Storybook To Preview Single Directory Components

Single Directory Components (SDC) consist of a directory of files that go together to create a small component on a Drupal website. The component contains all the templates, styles, script, and images needed to display some content in a consistent way.

Different SDC can be nested together, which means that a site can be built up from different components working together to generate the content.

The power of SDC comes from their ability to be self contained. If you have the need to build a complex component that displays data in a widget then building it as a SDC means that you can ensure that it looks and functions in the same way every time you include it.

Kiwi Ears Altruva Wired Headphones: A Review

Kiwi Ears Altruva are a set of wired headphones that have an opened backed design. They connect via a standard audio jack interface, which has a built in adapter so it's compatible with 3.5mm or 6.35mm connections.

I usually spend about an hour a day on video conference calls (sometimes much, much more than that) and I have a set of headphones that I use for this. Actually, I have used the same headphones for this purpose for the last 5 years so when Kiwi Ears reached out to offer me the Altruva headphones I was keen on giving them a go as my daily drivers.

In this article we will look at the Kiwi Ears Altruva headphones, their build quality, functionality, and how they sound.

Using Colour Schemes To Create Light And Dark Modes In CSS

Allowing users to switch between light and dark colour schemes on websites is a popular feature. You can often see a small sun or moon icon that allows you to change from light mode to dark colour scheme, or visa versa. Some operating systems and user agents also have the ability to activate a dark colour scheme, which websites also pick up and use.

This feature is so popular, in fact, that a number of browser extensions exist to allow users to force websites to be shown in certain colour schemes, the most popular ones making the site dark. Having a dark colour scheme on a website aids in readability, especially for people who have ADHD and similar disorders.

From a person perspective, having a dark colour scheme in a website means that I can view the content in the middle of the night without causing myself eye strain or disturbing anyone else. I often have trouble sleeping so the ability to read articles in the dark has become quite important to me.

Keychron Q13 Pro Wireless Mechanical Keyboard: A Review

The Keychron Q13 Pro is a full size keyboard that has wired and wireless capabilities, featuring 106 keys including 5 macro keys and a number pad.

The keyboard features an Alice layout, which means that the board is essentially split into two sections, with each section curved towards the lower middle of the board. The idea behind this is to give the keys a more natural position for the user to type on, preventing wrist stretching.

In a drive to keep typing as much as I do, whilst also not suffering from RSI, I was looking for Alice keyboards, and the Q13 Pro stood out. I have tried split keyboards in the past and didn't really get on with them, so I was curious to know if the sloped design would cause me problems with typing.

Drupal 11: Object Oriented Hooks And Hook Service Classes

Hooks are used in Drupal to allow modules and themes to listen to or trigger different sorts of events in a Drupal system. During these events Drupal will pause and ask if any modules want to have any say in the event that is currently being triggered.

For example, hooks are commonly used when content is viewed, created, updated, or deleted. So, if we delete a page of content then a delete hook is triggered which allows modules to react to that content item being deleted. Using this, we can react to this and perform clean up operations on items of content that don't exist any more. Our custom module might want to remove items from a database table, or delete associated files since they wont be needed.

This is just one example of how hooks are used in Drupal as they are used in all manner of different situations, and not just listening for content events. Another example of a common Drupal hook is when creating a custom template.