Index: sections.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/sections/sections.module,v
retrieving revision 1.16.2.27
diff -u -r1.16.2.27 sections.module
--- sections.module	20 Dec 2009 21:24:12 -0000	1.16.2.27
+++ sections.module	8 Aug 2010 11:49:39 -0000
@@ -90,18 +90,36 @@
     }
 
   }
-  else if ($section = sections_in_section()) {
-    // only switch to custom theme if theme is active, to prohibit a destroyed site
+
+  return $items;
+}
+
+/**
+ * Implementation of hook_init().
+ */
+function sections_init() {
+  if ($section = _sections_in_section()) {
+    _sections_switch_theme($section->theme);
+  }
+}
+
+/**
+ * Change the current theme to a custom theme.
+ *
+ * @param $theme
+ *   The theme_key of the custom theme that should be used.
+ */
+function _sections_switch_theme($theme_key = NULL) {
+  if (!empty($theme_key)) {
+    // Only switch to custom theme if theme is active, to prohibit a destroyed site.
     foreach (list_themes() as $key => $theme) {
-      if ($theme->status == 1 && $theme->name == $section->theme) {
+      if ($theme->status == 1 && $theme->name == $theme_key) {
         global $custom_theme;
-        $custom_theme = $section->theme;
+        $custom_theme = $theme_key;
         init_theme();
       }
     }
   }
-
-  return $items;
 }
 
 /**
