0

I am trying to use the garland theme on the blocks page rather than using my custom theme.

I have found this question: Force block page to use admin theme?

Which has given me a code snippet to use. I have placed this in the modules/block/block.admin.inc file on line 36.

The theme is still my custom theme and i must be doing something wrong. If possible i would rather not use a module.

The code i am using:

function mytheme_init() {
  // Hardcode the administration theme onto the blocks page
  if ($_GET['q'] == 'admin/build/block') {
    global $custom_theme;
    $theme = 'garland';
  }
}

Thanks!

1 Answer 1

1

FYI it's a REALLY bad idea to hack core. Firstly, God knows what could break, and secondly..whatever changes you make will likely be over-written if/when you update core.

To answer your question, you're calling the $custom_theme as you should, but then assigning a Garland to $theme, which isn't used.

Try the following:

function mytheme_init() {
  // Hardcode the administration theme onto the blocks page
  if ($_GET['q'] == 'admin/build/block') {
    global $custom_theme;
    $custom_theme = 'garland';
  }
}

In your custom theme's template.php instead of in block.admin.inc. Make sure you change mytheme to whatever your custom theme's name is (e.g. my_custom_theme_init or custom_init).

You might also want to look at the Administration Theme module or the Themekey module for admin theme options/theme switching.

Themekey sounds like a pretty good bet for ease of use:

ThemeKey allows you to define simple or sophisticated theme-switching rules which allow automatic selection of a theme depending on current path, taxonomy terms, language, node-type, and many, many other properties. It can also be easily extended to support additional properties exposed by other modules.

EDIT

I forgot, the Admin module also comes with an admin theme option, and a pretty decent admin menu for end users (clients etc.).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.