2
votes

As the title says,

I need to know the name of the theme being used in any drupal page.

For example we can set a default theme and a admin theme for our drupal site basically. For now lets consider only this part and don't get into user specific themes.

So in the above case the home page will load using default_theme and when you do to any admin pages, they will load in admin_theme(seven/bartik).

Now my question is I need to know what theme is being loaded when I navigate to any page of the site. May it be a node/add or node/edit or admin/* or page/* or any page.

Simply when I go to any page I shoudl know the theme name being used in that page and in which hook I can write my conditions.

Based on that I want to do some changes.

I tried using globals $theme, path_to_theme, drupal_get_path etc

When I use them ,they always return the default theme name and not the theme being used in a specific page.

I wrote exit statement for $variables in hook_preprocess_html and it returns value by exiting only if the page is normal users page. But not in admin pages like sitename/admin/content etc.,

Any one who can help.

Thanks in advance

1

1 Answers

2
votes

Create a custom module, and put your code in function hook_init(){} in your .module.

No arguments.

function example_init() {
    global $theme; 
    print $theme.'<br />';  // current theme name 

    print $GLOBALS['theme'].'<br />';   // current theme name 

    $theme_path = drupal_get_path('theme', $GLOBALS['theme']); 
    print $theme_path.'<br />'; // path to current theme
}