I usually test my new themes within a test environment but sometimes I need to test on the production site.
I would like to be able to awitch to a theme without having the need to enable it first. Especially because I need some user-roles (that have permission) to review those themes before enabling them.
I would like propose attached patch:

  • adds a permission "switch to non-enabled theme"
  • If you have permission to use non-enabled themes there will be a small note ön the theme switch form saying: "Non-enabled themes available".
  • Corrected some coding-standard-things
CommentFileSizeAuthor
#9 nonenabled_d5.patch1.27 KBclivesj
swt_non_enable.patch1.56 KBclivesj
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Component: User interface » Code
Status: Active » Needs work

I like this idea. However, your coding-style needs work, see http://drupal.org/coding-standards for further information.

clivesj’s picture

Thanks Sun, can you point some more specific where I missed the standards?

sun’s picture

- Insert a space after the comma to separate array values.
- Use 2 spaces instead of tabs.
- Else is always on the next line, same indent as If.
...if you already read the coding standards section in the handbooks, then read it again, please. All of this is clearly stated there. Either read, understand, and adapt Drupal's coding standards, or do not post patches. Thanks.

Other than that:
- $note is not initialized.
- We do not use dirty HTML hacks like the one in #suffix in Drupal.
- You accidently removed the form submit button in switchtheme_switch_form().

clivesj’s picture

Thanks for the pointers,
I will re-do my homework and re-supply a patch

christefano’s picture

I've noticed on occasion that for anonymous visitors, Switchtheme somehow switched to a theme after the theme has been disabled. It's strange to see this as a feature request.

sun’s picture

@christefano: This issue is a feature request. What you are reporting is a completely separate issue. Please open a new bug report for it. Thanks.

christefano’s picture

@sun: I'm aware that this is a feature request and noted that in my comment. If you prefer that I just write "subscribing" instead please let me know. :)

sun’s picture

Any updates?

clivesj’s picture

FileSize
1.27 KB

Here's a patch i'm using on my D5 site.
I will install and test the D6 version on my D6 site and provide the patch when ready.
regards

sun’s picture

+++ switchtheme_patch.module	2008-12-15 13:46:29.281250000 +0100
@@ -23,7 +23,7 @@ function switchtheme_help($section) {
+  return array('administer switch', 'switch theme', 'switch to non-enabled themes');

Uhm - why not simply:

s/non-enabled/disabled/ ;)

+++ switchtheme_patch.module	2008-12-15 13:46:29.281250000 +0100
@@ -121,7 +121,8 @@ function switchtheme_switch_form() {
+    '#description' => user_access('switch to non-enabled themes') ? t('Non-enabled themes available') : '',

I don't think this description is of any help...

+++ switchtheme_patch.module	2008-12-15 13:46:29.281250000 +0100
@@ -164,7 +165,10 @@ function switchtheme_options() {
-    if ($attr->status) {
+    if (user_access('switch to non-enabled themes')) {
+      $options[] = $attr-> name;
+    }
+    elseif ($attr->status) {
       $options[] = $attr->name;
     }

Instead, we should store $attr->name as key and "@themename (disabled)" as value for $options here.

Beer-o-mania starts in 20 days! Don't drink and patch.

mikesir87’s picture

Is this in the current version of the code? I am able to switch to the Garland theme, even when it is not enabled. I see this as being a problem, so would like to suggest creating a permission to allow someone to switch to a non-enabled theme. I don't want anonymous users to be able to switch to any theme they want.

Thoughts?