Created
June 15, 2013 22:42
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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