• Development

    Using Drupal 8 Persistent Login Module on Platform.sh

    The Persistent Login module relies an extra cookie to maintain a Drupal user’s session. The configuration screen for this module lets you specify a prefix for the cookie. The default is “PL”. If you are using the site on HTTPS, the module prepends an “S” to the cookie it creates. Here’s an example cookie name: SPLfa0650d6d985433d455a3b15cc70fd9b .
    Platform.sh lets you configure cookie cache settings via routes.yaml .
    If you’re using Persistent Login you must tell the system not to ignore this cookie.
    Here’s a standard (and simple) routes.yaml  file on a Drupal 8 site:
    Here’s a modified version which allows Persistent Login to work correctly:

     

    There is a bit more discussion around how these cookies are handled here: https://www.drupal.org/node/2898065/discuss

  • Development

    Using Lazy Builders and Auto Placeholders in Drupal 8

    Introduction

    I’ve been working on a site that features a lot of user-specific customization and output. The site offers workshops (courses) using the Opigno LMS for Drupal 8. The workshops are rendered in a few different ways throughout the site. For the most part, the rendered workshops appear the same for all users. Here’s an example of a “card” view mode for a workshop:

    If a user has successfully completed a workshop, a special badge will appear on the card view mode. Also, the card will be highlighted:

    There are two parts of the workshop card template that have to change based on the user viewing the card:

  • Uncategorized

    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, varnish cache clearing, and clearing the cache through the Drupal UI.

    After reading through No reliable method exists for clearing the Twig cache, I landed on this page at Acquia: https://support.acquia.com/hc/en-us/articles/360005167754-Drupal-8-Twig-cache

    I SSH’d into the production server I always SSH into, and I ran the command as shown. I did this repeatedly. I did a drush cr after. I did a drush cr before. Nothing was working. My pages were showing up with the old template, or the new template, and it seemed to be at random.

    Ultimately I re-read the documentation page, more thoroughly this time, and discovered this: “connect to each web server instance and run a command like this…

    Ahah! EACH web server.

    So, I logged into the Acquia Cloud interface, found the other production server’s connection string (myuser@someserver.prod.hosting.acquia.com), connected, and ran the same command. After another drush cr all of the pages were using the new template.

    That’ll teach me to jump straight to executing commands without reading the instructions carefully.