- πΊπΈUnited States trackleft2 Tucson, AZ πΊπΈ
Interestingly enough, Environment Indicator module doesn't actually keep track of the environment it is on, nor does it have rules for getting that information.
However, if you are working on a site with the environment indicators set up you should be able to use the environment information in a round-about way with something like twig_tweak β
{{ drupal_config(config_name, key) }}
{% set indicator = drupal_config('environment_indicator', 'indicator') %} {% if indicator.get('name') == 'Local Dev' %} <p>Show local something html locally</p> {% else %} <p>Everything for the live site</p> {% endif %}
This is assuming you have something like this in your site's settings.php
/** * Environment Indicator module settings. * see: https://pantheon.io/docs/environment-indicator */ // Pantheon Env Specific Config if (isset($_ENV['PANTHEON_ENVIRONMENT'])) { switch ($_ENV['PANTHEON_ENVIRONMENT']) { case 'lando': // Localdev or Lando environments. $config['environment_indicator.indicator']['name'] = 'Local Dev'; $config['environment_indicator.indicator']['bg_color'] = '#990055'; break; case 'dev': $config['environment_indicator.indicator']['name'] = 'Dev'; $config['environment_indicator.indicator']['bg_color'] = '#4a634e'; break; case 'test': $config['environment_indicator.indicator']['name'] = 'Test'; $config['environment_indicator.indicator']['bg_color'] = '#a95c42'; break; case 'live': $config['environment_indicator.indicator']['name'] = 'LIVE'; break; default: // Multidev catchall. $config['environment_indicator.indicator']['name'] = 'Multidev: ' . $_ENV['PANTHEON_ENVIRONMENT']; $config['environment_indicator.indicator']['bg_color'] = '#1e5288'; break; } } } else { $config['environment_indicator.indicator']['name'] = 'Local'; $config['environment_indicator.indicator']['bg_color'] = '#707070'; }