Displaying a different theme for each day of the week
This recipe provides the PHP code that allows the rotation of themes based on the day of the week.
Getting ready
As we have seen in other recipes in this chapter, a number of sites use an "odds and ends" module to handle tweaks and customizations particular to the site. We will be using the mysite.module
created earlier in this chapter to hold our customizations. It is assumed that the module is available and already enabled.
How to do it...
Open the mysite
module file and paste the following code into it:
/** * Implementation of hook_init(). */ function mysite_init() { global $custom_theme; // An array of themes for each day of the week. // These themes do not have to be enabled. $themes = array(); $themes[0] = 'garland'; $themes[1] = 'minnelli'; $themes[2] = 'bluemarine'; $themes[3] = 'pushbutton'; $themes[4] = 'chameleon'; $themes[5] = 'marvin'; $themes[6] = 'mytheme'; // Get the current day of the week in numerical form. $day = date("w...