Last month, Open Atrium released one of their largest upgrades since version 2. Included in this upgrade is a complete revamp of the theme layer. You can read more about the changes in 2.6 here: A Fresh New Look for Atrium.
There is some documentation on creating a subtheme from oa_radix, OpenAtrium 2.5’s base theme but, unfortunately, the documentation for subtheming 2.6’s base theme, oa_basetheme, hasn’t been created by the maintainers just yet.
We’re trying to get this upgrade out to our users ASAP so, today, I spent some time fiddling with creating a new subtheme for Open Atrium 2.6x. In this tutorial, we’ll go over what I’ve found:
The oa_basetheme comes with bootswatch and, using Drush, we are supposedly able to install an ‘instant subtheme’ by executing:
drush en oa_basetheme -y
drush oa_basetheme "My Subtheme"
There are various options for this command, if you’d like to provide a machine name or use a different bootswatch theme. You can find these options by running:
drush help oa_basetheme
So, from my site’s directory (sites/default), I tried to run:
drush oa_basetheme "My Subtheme"
and was presented with
Constant BOOTSWATCH_URI already defined oa_radix.drush.inc:10 [notice]
Command oa_basetheme needs the following module(s) enabled to run: oa_basetheme. [error]
The drush command 'oa_basetheme my_oa_theme' could not be executed. [error]
This issue had been reported on d.o, but that thread lead to no results.
Creating a Subtheme
After some finagling and trial-and-error, I was able to get the starter subtheme created by performing the following steps:
- Copy oa_basetheme from “docroot/profiles/openatrium/themes” to my site’s theme directory, “docroot/sites/default/themes”:
1cp docroot/profiles/openatrium/themes/oa_basetheme docroot/sites/default/themes
- Enable the theme with Drush:
1drush en oa_basetheme -y
- Browse to Appearance Config (/admin/appearance) and select Set As Default for oa_basetheme.
- Run the oa_basetheme bootswatch starter Drush command:
1drush oa_basetheme "My Subtheme"
No errors this time! I’m honestly not sure if the resolution was the fact that I moved oa_basetheme from the Open Atrium profile to sites/default or the fact that I set oa_basetheme as the Default theme. I’m inclined to think the fix was the latter since the error was a Bootswatch conflict with oa_radix, but, alas, I have yet to actually confirm this.
This will put the new subtheme in “docroot/sites/all/themes”. If you don’t need it in /sites/all, be sure to move it to /sites/default.1mv /docroot/sites/all/themes/my_subtheme /docroot/sites/default/themes
- Browse to Appearance Config (/admin/appearance) and select Set as Default for the original theme from Step 3.
- Remove the copy of oa_basetheme from your site’s theme directory
1rm -rf docroot/sites/default/themes/oa_basetheme
Now, if you have a fresh install of OpenAtrium 2.6x, you can go ahead and “Enable and Set as Default” directly from Appearance Config (/admin/appearance) and you’ll be good to go!
Upgrading from 2.5x to 2.6x?
However, if you, like me, are upgrading an existing OpenAtrium site from 2.5x to 2.6x, there are a few more steps you need to take to enable all the new features of the theme.
- Enable the Open Atrium Site Layout Defaults module. This is a module that ships with OA 2.6x and contains the default panels config required for the new functionality in the new 2.6x theme.
1drush en oa_site_layout_defaults -y
This will also enable dependencies: oa_site_layout and panels_everywhere
- Go ahead and Enable your new subtheme in Appearance Config (/admin/appearance) but do not Set As Default just yet.
- The OA base theme’s panel layout is defined in a Page called site_template for the Panels Everywhere module, however, out of the box, it’s configured to be used only when the current theme is either oa_theme or oa_basetheme.Since we have a new subtheme, we need to update the selection rules for the pertinent Variant within that Page to use the Variant for our new subtheme as well. Sooo… browse to “/admin/structure/pages/nojs/operation/site_template/handlers/site_template__atrium-modern/criteria” (or go to Admin > Structure > Pages > Edit site template Tab > Selection Rules)
- Under the Criteria Table, select “Current theme” from the drop down and click the “Add” button.
- Select your new subtheme from the dropdown menu and click the “Save” button.
- Click the “Update and Save” button at the bottom of the Variant Options for the Default site template page.
- Finally, go back to Appearance Config (/admin/appearance) and select Set as Default for your new subtheme.
- Clear caches and you’re all set to start working on the theme’s code itself.
1drush cc all
One more thing… Regarding Concurrent Themes
We are currently planning to deploy our new subtheme to a subset of users: a beta group.
To accomplish that, forego Step 7 of the previous list, leaving your old 2.5x theme as Default and your new subtheme simply Enabled. Follow these steps to install and configure ThemeKey and ThemeKey User Profile.
- Install and enable ThemeKey and ThemeKey User Profile
123drush dl themekeydrush en themekey -ydrush en themekey_user_profile -y
- Browse to the UI Settings for ThemeKey (/admin/config/user-interface/themekey/settings/ui), expand the Selectable Themes table and check the checkbox for your old 2.5x theme and your new 2.6x subtheme.
- In the UI Settings table, select “Add theme option to user profile”.
- Click the “Save configuration” button.
- Browse to User Permissions configuration page, and ensure the permission: “Select different theme” is enabled for your required roles (in most cases, authenticated user). Or, add the permission to the role with Drush:
1drush role-add-perm 'authenticated-user' 'select different theme'
Now when a user browses to their Edit Profile page, they’ll be presented with a field to select the theme to use.