Drupal provides a handy of global variables. Thanks for the tiring efforts. You might know about the interfaces in drupal, it has a use interface and an admin interface. Suppose we are using bartik as our user theme and seven for admin interface.
My requirement was a bit quirky. In the admin configuration, I have to get the path of user theme. First thing came into my mind was the global variables. And it was,
But the output of the variable was a bit surprising, I thought it would return bartik, but it was returning 'themes/seven'. As code executes only in the admin side, the variable was returning the path of the active theme on the admin side.
I have played with many other global variables related to theme, but all has to offer something related to seven theme. So what next? Isn't there any clue that would point to bartik. Yes, there is. Drupal provides an ample number of variable's for this purpose. One of the variables that would get through our requirement is,
This will return the current and active theme. If we changes the theme on user side, it is going to give the theme to which the it has been switched.
To get the path of the theme, you might know,
$active_theme = variable_get('theme_default'); $active_theme_path = drupal_get_path('theme', $active_theme);
Now the variable $active_theme_path has the path to the bartik theme. There are pretty much variables are set by the drupal maintainers and builders to make the platform more handy and tolerable.