14

Our deployment model has

  1. Dev
  2. Stage
  3. Production
  4. Failover (mysql replication and load balancer)

Our problem is that the server has failed over, we want to alert content editors that they're on the failover, or moreso, we'd like to ensure they're editing in the production areas and not on a development box.

Is there a way to distinguish the environment, after a user logs in? Is there a module by which color codes the admin bar depending on the server's host name?

14

Try Environment Indicator, it does exactly what you want.

This module will help you to keep sane while working on your different environments by adding a configurable color bar to each one of your environments.

It also integrates nicely with Admin Menu.

7

As mentioned in the 1st answer, environment_indicator is the one you are looking for.

Well, we also use the same kind of development model and for ease of use if features module is used then you can have the settings written in a file. This makes the colour changing automated.

Follow the code below, this can be imported via Features module.

/**
 * Implements hook_default_environment_indicator_environment().
 */
function mymodule_default_environment_indicator_environment() {
  $export = array();

  $environment = new stdClass();
  $environment->disabled = FALSE; /* Edit this to true to make a default environment disabled initially */
  $environment->api_version = 1;
  $environment->machine = 'live';
  $environment->name = 'Live';
  $environment->regexurl = 'example.com';
  $environment->settings = array(
    'color' => '#bb0000',
    'text_color' => '#ffffff',
    'weight' => '',
    'position' => 'top',
    'fixed' => 0,
  );
  $export['live'] = $environment;

  $environment = new stdClass();
  $environment->disabled = FALSE; /* Edit this to true to make a default environment disabled initially */
  $environment->api_version = 1;
  $environment->machine = 'staging';
  $environment->name = 'Staging';
  $environment->regexurl = 'stage.example.com';
  $environment->settings = array(
    'color' => '#000099',
    'text_color' => '#ffffff',
    'weight' => '',
    'position' => 'top',
    'fixed' => 0,
  );
  $export['staging'] = $environment;

  $environment = new stdClass();
  $environment->disabled = FALSE; /* Edit this to true to make a default environment disabled initially */
  $environment->api_version = 1;
  $environment->machine = 'dev';
  $environment->name = 'Dev';
  $environment->regexurl = 'dev.example.com';
  $environment->settings = array(
    'color' => '#000066',
    'text_color' => '#ffffff',
    'weight' => '',
    'position' => 'top',
    'fixed' => 0,
  );
  $export['dev'] = $environment;

  return $export;
}
  • Selected the module answer but still an up-vote for this. Many, many thanks. – Rick Jul 9 '14 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.