Theme colour switcher

Blog Topic: Drupal

This is probably a pretty niche topic, but for anyone out there using the Group module and the very useful Entity Group Field module to add content to groups, it may be handy. I previously posted about how to get the rendered value of this field in Twig, but what if you want/need to get individual raw values? Today I had to do just that; I needed to check the type of each group referenced from…

Continue reading

I wanted to create a view of "event" content type, grouped by taxonomy term. For each group, I wanted to show only the first 4 items, with a "more" link to see all. This seems like it should be a simple task, but isn't, and isn't possible out of the box with views. I didn't want to have to create a view display for every taxonomy term. That's a huge pain, requires maintenance every time a new…

Continue reading

This post piggybacks on my earlier post "Print raw values from Smart Date fields in Twig templates - Drupal 8+". The Drupal Smart Date module allows users to choose a timezone for each date entered in a Smart Date field. One of my clients has a site with an event content type that uses a Smart Date field, and they needed event dates and times to display in the actual timezone entered. However, no…

Continue reading

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

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

    <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

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

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

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