Blog Archives

Drupal 8 – Formatting a Date Field in Twig

Here are the four easiest ways I’ve found to show dates via Twig inside of a node template. They all result in the same output. Use the field’s formatter settings; include wrappers

This is the only example that includes wrappers.

Tagged with: , ,
Posted in Development

Quick and Dirty Debugging of Drupal 8 Migrations

Introduction If you’re working on a migration in Drupal 8 and you’re finding yourself a little confused by the YAML-based configuration, I strongly recommend using a proper debugger so you can step through the code. You cannot step through the YAML,

Tagged with: , ,
Posted in Development

Database Refreshing Pattern in Drupal 8 – Testing Config Changes

I’ve been working on some Drupal 8 migration work. Given that most of the work I’m doing takes place in “config” I have to keep refreshing/reinstalling the config on my site. For a long time I would use Configuration Installer to

Tagged with: ,
Posted in Development

Adding Entity Wrapper Class from Field Value using Display Suite

NOTICE: This works fine in Drupal 7. For Drupal 8 please see https://www.drupal.org/node/2863420 Sometimes as a developer you need to provide your Drupal authors with the ability to choose different variations of a particular content object. For example, imagine you have a Callout paragraph bundle

Tagged with: , , , ,
Posted in Tech Tips

Friendly URL for Views Contextual Filter on a Boolean Field

I have a story content type that has a corresponding Views listing page. The stories can be flagged as Featured through a checkbox/boolean field ( field_story_featured ). The stories also have a Story Type value ( field_story_type ). The views listing page needs to have the

Tagged with: , ,
Posted in Development

Quickly Implement a Block as a Paragraph in Drupal 7

Disclaimer: As with most tasks in Drupal, there are several ways to do this. My goal here was to see how quickly it could be done without writing code and without introducing unnecessary complexity. Goal — quickly implement a newsletter

Tagged with: , , , , ,
Posted in Development

Sort “Select an existing field” options in Drupal by Label instead of Type

Normally Drupal sorts the “Select an existing field” select list by the field types. Here’s an example of what this looks like: This looks good at first glance, but often it’s hard to quickly find the field you want to

Tagged with: , ,
Posted in Development

Bulk Add URL Redirects in Drupal 7

Here’s a quick example showing how to add URL redirects (for the redirect module) in bulk. Instead of a separate page for each list of “fellows”, we built a single view with exposed filters to choose a semester. The original

Tagged with: ,
Posted in Development

Adding a “Filter by year” Facet for a Date Field in Apachesolr for Drupal 7

A Drupal 7 site I’m working on makes use of the Apache Solr Search module and FacetAPI. Some of the content has a date field named field_s_date. I was tasked with providing a sidebar “Filter by year” facet block to filter

Tagged with: , , ,
Posted in Development