Needs review
Project:
Admin
Version:
6.x-2.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Nov 2010 at 21:02 UTC
Updated:
4 Jun 2011 at 06:41 UTC
If you want a new permission called "use admin theme" you can patch the module with these simple modifications:
Modify the admin_perm() function to this:
function admin_perm() {
return array('use admin toolbar', 'use admin theme');
}
Add this code to admin_init():
// Use the administrative theme if the user is looking at a page in the admin/* path.
if (!user_access('use admin theme')) {
global $custom_theme;
$custom_theme = variable_get('theme_default','none');;
}
so that the function looks like this:
/**
* Implementation of hook_init().
*/
function admin_init() {
if (arg(0) === 'admin') {
menu_set_active_menu_name('admin');
}
if (user_access('use admin toolbar')) {
$path = drupal_get_path('module', 'admin');
drupal_add_js("{$path}/includes/jquery.cookie.js");
drupal_add_js("{$path}/includes/jquery.drilldown.js");
drupal_add_js("{$path}/includes/admin.toolbar.js");
drupal_add_js("{$path}/includes/admin.menu.js");
drupal_add_css("{$path}/includes/admin.toolbar.base.css");
drupal_add_css("{$path}/includes/admin.toolbar.css");
drupal_add_css("{$path}/includes/admin.menu.css");
}
// Use the administrative theme if the user is looking at a page in the admin/* path.
if (!user_access('use admin theme')) {
global $custom_theme;
$custom_theme = variable_get('theme_default','none');;
}
}
Comments
Comment #1
jlmeredithGreat info! Worked like a charm! Thanks for the great code snippet. This should seriously be in the core module.
Comment #2
pixelsweatshop commented+1 for this feature.
Comment #3
thedavidmeister commentedthanks for this, works a treat with no nasty side effects afaik :)
made my life a whole lot easier today, as I wanted to give my contributors access to the nice, clean "Rubik" theme for content editing, yet Admin started showing it to users starting new forum topics.
+1 for this feature
Comment #4
patrickroma commentedgreat!
Comment #5
thedavidmeister commentedcould we get this committed? i'm using it in every second project i'm working on atm.
Comment #6
mkalkbrennerThis patch is incompatible with theme switching modules like ThemeKey. (see #1169504: Conflict with admin module)
BTW the default theme is 'garland' and not 'none'.
Comment #7
thedavidmeister commented@mkalkbrenner: the default theme is set to 'none' by the Admin module, not this patch so you should open a new issue for that