0
votes

A site I'm creating for a customer in D6 has various images overlaying parts of the main content area. It looks very pretty and they have to be there for the general effect.

The problem is, if you use this theme in the administration pages, the images get in the way of everything.

My solution was to create a custom admin theme, based on the default one, which has these image areas disabled in the output template files - page.tpl.php

The problem is that when you try and edit the blocks page, it uses the default theme and half the blocks admin settings are unclickable behind the images. I KNOW this is by design in Drupal, but it's annoying the hell out of me and is edging towards "bug" rather than "feature" in my mind. It also appears that there is no way of getting around it.

You can edit /modules/blocks/block.admin.inc to force Drupal to show the blocks page in the chosen admin theme. BUT whichever changes you then make will not be transferred to the default theme, as Drupal treats each theme separately and each theme can have different block layouts. :x

function block_admin_display($theme = NULL) {
  global $custom_theme;

  // If non-default theme configuration has been selected, set the custom theme.
  // $custom_theme = isset($theme) ? $theme : variable_get('theme_default', 'garland');
  // Display admin theme
  $custom_theme = variable_get('admin_theme', '0');

  // Fetch and sort blocks
  $blocks = _block_rehash();
  usort($blocks, '_block_compare');

  return drupal_get_form('block_admin_display_form', $blocks, $theme);
}

Can anyone help? the only thing I can think of is to push the $content area well below the areas where the image appear and use blocks only for content display.

Thanks!

6

6 Answers

1
votes

you can apply admin theme wherever you want using hook_init() in your custom module:

function yourmodule_init() 
{
    if ( some condition here like arg(0) == 'foobar' 
         or node_load(arg(1))->type == 'something' )
    {
      $GLOBALS['custom_theme'] = variable_get('admin_theme', '0');
      drupal_add_css(drupal_get_path('module', 'system') .'/admin.css', 'module');
      drupal_add_js(drupal_get_path('theme', 'myadmintheme').'/jscripts/adminjs.js');
    }
}

EDIT: then (probably) you have to use form_alter against the block editing form to restore the target theme. in this way you don't have to hack the core.

2
votes

in template.php you can put

function YOURTHEME_preprocess_page(&$vars) {
  if (implode('/', arg()) == 'admin/build/block'){
    $vars['body_classes'] = $vars['body_classes'].' administer_block';
  }
}
and you'll have a nice body class which you can use to hide those images using CSS.

2
votes

If anyone's still having a problem with this, a bit similar to barraponto's solution above, if you are using the admin menu module, it adds a class (.admin-menu) to the body, which you can use to hide any overlaying divs etc that are getting in the way.

0
votes

Thanks for bringing up this topic! I was having the same problem, and it's annoying. Here's how to remedy it without a single line of code: 1) Switch the main theme to your administration theme. 2) Configure Blocks. This always affects the currently selected main theme. 3) Switch the main theme back to what it's supposed to be. Your admin theme will still reflect your changes.

0
votes

could just use the block-admin..... tpl file from block module and theme it in your custom theme. I have done this way as admin theme module never overrides block admin even when you use custom path bit.

-1
votes

If you don't need your new theme while performing administration tasks, you can use a different theme while doing so.

Goto "Site Configuration" -> "Administration Theme". Here you can pick the theme to be used while doing admin. So your new theme is only used while users are viewing your site. And you can do admin tasks without the interference of all your images.