Theme colour switcher

Blog Topic: how to

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

The Drupal Responsive Background Image module is a nice little module that gives you a preprocess function to display an image field as a, you guessed it, responsive background image. This is useful for hero images, when you want the image to display at different sizes on different-size screens, because you don't want to load an enormous 2000+-pixel-wide image on mobile screens. The creator of…

Continue reading How to use Responsive Background Image in a page or node template

Just plopping this here for future reference and in case it might be useful to someone. I'm having to work with a platform which shall remain unnamed but whose code makes working with it very difficult. Among other things, it gives form elements unique classes with ID numbers, but for some reason no IDs. So I needed to filter the class list to find the unique class so I can set the element's ID…

Continue reading JavaScript function to find a class on an element containing a particular string