• 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 try to do it with only Twig. The result is moderately readable.

    Twig Code:

    For a taxonomy term reference field called field_pub_tr_res_committees

    Output:

    If 1 value: My first term

  • Development

    Maintaining Lightbox2 Templating

    Lightbox2 is a very popular and powerful Drupal module. One of the helpful features is that you can render a Drupal node in a lightbox rather easily in either PHP or HTML. View detailed explanation. The issue is that when you click a link within that lightboxed content, you will lose the lightbox2 templating (e.g., if your lightbox template hides sidebars, they’ll only be hidden when the node loads. If you click a link within the lightbox, the new node will load and sidebars will appear). Read on for a quick fix.