• 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 template file so you cannot simply override via Twig.

    If your goal is to simply hide the country value from the output you can use hook_preprocess_field to alter the country value. As it turns out, unsetting the country field doesn’t help, but setting the value to an empty string does work.

    Here’s an example (in a module; you can put in your .theme file if you’d prefer the setting to be at the theme level).

     

  • Development

    Tideways and Xhgui in Valet+ (Valet Plus)

    This post is for folks who are already familiar with PHP, command line, Valet, Tideways and XHGui.

    You can see some explanation and screenshots of Tideways and Xhgui in my Tideways and Xhgui using Dev Desktop post if you need a bit of an introduction.

    I’ve successfully gotten Tideways running with Acquia Dev Desktop, Lando, and now Valet+. This post illustrates the process I used to get Tideways, Xhgui, and their dependencies running on my Mac for use in Valet+ sites.

  • 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: