Blog Archives

Twig Caching Issues in Acquia Cloud Enterprise

I’ve recently run into an issue where my site (on Acquia Cloud Enterprise) has node displays that were flip-flopping between an older version of a Twig template file, and the most recent version. I tried all combinations of drush cr,

Tagged with: , , ,
Posted in Uncategorized

Migrating Into Existing Nodes in Drupal 8, Including Rollback Missing from Source

Please read this entire post (including the disclaimer at the bottom) before you put any of it to use. The site I’m basing this off had an existing set of nodes and a new migration that had the same nodes (and

Tagged with: , ,
Posted in Development

Combining Steps in Behat for Drupal

Lately I have found myself repeating several lines of behat steps over and over again. Here is a sample of the behat code I use to choose a specific checkbox from an entity browser popup:

There are a few steps in here

Tagged with: ,
Posted in Development

Adding Level Number Class to Menu Items in Drupal 8

This is a quick post showing how to add level classes to menu items in Drupal 8. Here’s the result, showing the additional menu--level-N  and menu-item--level-N  classes: Step 1: Create a New Twig template File Determine which Twig template you need to

Tagged with: , ,
Posted in Development

Hiding Country from an Address Field’s Output in Drupal 8

There are two field formatters available on an Address field in Drupal 8: The Plain formatter uses a Twig template file but it would take some work to override with the proper markup. The Default formatter doesn’t use a Twig

Tagged with: , ,
Posted in Development

Access Entity Properties in a Field Twig Template

This doesn’t need much of an explanation. You can use any entity methods as far as I can tell. Here’s an example showing how to get the node ID in a field template:

 

Tagged with: ,
Posted in Development

Modifying Rows During a Drupal 8 CSV Migration

Migrate Source CSV is currently the source plugin of choice for doing a CSV-to-Drupal migration with the Migrate API in Drupal 8. In this post I will demonstrate how to manipulate the CSV data in realtime during the migrate:import operation.

Tagged with: , , , ,
Posted in Development

404 Error Serving a /libraries page in Drupal 8

It took some time to figure out why I kept seeing a 404 error (page not found) on http://www.mysite.com/libraries. The issue seemed to only present itself on our Acquia environments. Ultimately I realized that there was a conflict due to

Tagged with: , ,
Posted in Development

Joining Strings in a Drupal Views Field using Twig

I have two optional fields on a Drupal 8 content type: City and State. Both are rendered as simple text. In a fields-based View I wanted to show the field output as “Portland” or “Portland, OR”, or “OR”. First, I added the two

Tagged with: , , ,
Posted in Development

Drupal + Twig: Render Taxonomy Terms and Comma-Separated List

Here’s a snippet that renders the terms in a multi-value taxonomy reference field (in a node template) as plain text items separated by commas. Yes, you could get the string into the desired format using PHP, but I wanted to

Tagged with: , ,
Posted in Development