Automatically exporting contexts

A few weeks ago I wrote a helper module which allows you to automatically export contexts created via the Context module into code, and then instantly provide them as default contexts. I've just released this module on Drupal.org.

While many developers use the fantastic Features module to export their contexts, that can lead to issues when a context contains blocks from a view, but that view is included in a different feature. When you add a context to a feature, Feature's dependencies functionality will bundle any views used in the context along with the feature, and if those views are included in a different feature, you will end up getting a conflict within the Features module. Context Export was written to avoid this issue, but still keep all contexts in code.

Context Export should be configured at /admin/structure/context/context_export to specify the directory in which exported contexts should be stored; this directory must be writable by the server. While the module provides a link to export all overridden contexts on /admin/structure/context, there is also an option to automatically export contexts. When using automatic export, please note that contexts do not get exported as soon as you save the context configuration form, but rather on the next page load.