Please implement admin theme support (use the admin theme for node cloning if it is also used for node editing).

It seems like the easiest way to do this is to add a hook_init with the following:


if (variable_get('node_admin_theme', '0') && arg(0) == 'node' && arg(2) == 'clone') {
    global $custom_theme;
    $custom_theme = variable_get('admin_theme', '0');
    drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
  }

Comments

pwolanin’s picture

yes, that seems to be what system module is doing (in a pathetically inflexible way)

http://api.drupal.org/api/function/system_init/6

kwinters’s picture

Status: Active » Needs review
StatusFileSize
new1000 bytes

Provided patch against HEAD, added documentation.

There doesn't appear to be a better way to do this in D6.

pwolanin’s picture

Looks reasonable - does it work?

kwinters’s picture

Yes. To test, apply the patch, set an admin theme with "Use administration theme for content editing" enabled. Find a node, hit Clone. The theme applied should be the same as for Edit.

If you don't check the content editing box, both Edit and Clone will use the main site theme instead of the admin theme.

tripngroove’s picture

Great patch, thanks! Someone needs to merge this in :)

cyberwolf’s picture

Subscribing.

cyberwolf’s picture

I used the themekey module to accomplish the same behavior, as a workaround.

In admin/settings/themekey, I added the following rule: drupal:path = node/#/clone
Just mentioning it here in case someone needs it.

pwolanin’s picture

Status: Needs review » Patch (to be ported)

comitted to 6.x-1.x. Need to be ported to Drupal 7 version whenever that's ready.

khaled.zaidan’s picture

StatusFileSize
new644 bytes

I just found an issue regarding this code.

It works fine as long as no other module has already invoked a call to init_theme().
But it is possible that another module's hook_init() might invoke a function from theme.inc which might cause the invokation of init_theme(). init_theme() sets the global variable $theme, and then when it's called again it doesn't execute anything. The simplest fix would be to unset it :)

Attached is a patch for this :)

khaled.zaidan’s picture

Actually i'm not so sure about the patch i submitted in my previous comment. It needs to be verified performance-wise. (could this be causing the theme registry to be rebuilt on every page request?)