Skip to content

Instantly share code, notes, and snippets.

@mindmergedesign
Created June 15, 2013 22:42
Show Gist options
  • Select an option

  • Save mindmergedesign/5789853 to your computer and use it in GitHub Desktop.

Select an option

Save mindmergedesign/5789853 to your computer and use it in GitHub Desktop.
Style your Drupal theme according to the time of the day by adding a "night" or "day" classes to the body.
/**
* Implements template_preprocess_html().
*/
function YOUR_THEME_preprocess_html(&$vars) {
// Day / night background theming.
$hour = date('G');
$theme = 'day';
if ($hour <= 6) {
$theme = 'night';
}
elseif ($hour >= 6 && $hour <= 18) {
$theme = 'day';
}
elseif ($hour >= 18) {
$theme = 'night';
}
$vars['classes_array'][] = $theme;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment