Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 11 down vote accepted

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.

share|improve this answer

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;
}
share|improve this answer
    
Selected the module answer but still an up-vote for this. Many, many thanks. –  rgchi Jul 9 at 17:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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