November 18, 2024
Please note I'm not referring here to showing a block with a list of content that shares the same taxonomy terms as the content it is displayed on, a.k.a. a "related content" block. There are reams and reams of tutorials out there showing you how to do that.
This use case is when you have a specific block, maybe just some custom output, that you only want to show on content that is tagged with…
Continue reading How to show a Drupal block on content tagged with specific taxonomy terms
November 7, 2024
A common need when displaying dates on a website is to display the start and end date of an event. If your date field is a standard Drupal datetime or daterange field, that's fairly easy. (See my post on how to get values from Drupal date fields in Twig).
If your date field is a Smart Date field and allows for recurrence, that's slightly more complicated, as it is now a multi-value field (…
Continue reading Get specific key values from multi-value field, e.g. first and last dates from recurring Smart Date field
September 6, 2024
<a href="{{ file_url(node.field_document.entity.field_media_document.entity.uri.value) }}"> {{ node.field_document.entity.field_media_document.entity.filename.value }} </a>
Of course you'll need to replace the fieldnames with yours.
The file_url function is necessary to transform the URL into a workable…
Continue reading How to get file URI and filename from referenced media entity field in Twig
August 29, 2024
One of my clients is a site which has extensive audio recordings. Their current site uses the default HTML5 audio player, but they want something that is more customizable to fit with their design and needs.
One of their requests was to be able to set audio playback speed. One of my priorities was that the audio player be fully accessible.
To display the audio player, they are using the Drupal…
Continue reading How I customized jPlayer for accessibility and added playback rate control, Drupal 9
November 3, 2023
Background: I work on a site with different groups of users, to manage which we use not only core Drupal roles and permissions, but the Group module. Recently the site owner requested to add a Workflow to a content type. Clients need to be able to see the workflow state and change it, but not be able to see or edit the original node, or even the workflow tab on the node.
We manage client access…
Continue reading Allow users to update an entity's Workflow status from a Drupal view
December 20, 2022
Recently I discovered an odd Drupal Views bug. While testing a view I realized that content it should have shown was missing from one display. After a lot of testing, it turned out it was due to two relationships to content in entity reference fields on the content type my view displays. These fields were empty in the missing nodes. Removing the relationships or adding content to those fields…
Continue reading Drupal views doesn't show content if entity reference field relationship is empty