Is there a $variable that contains the current theme name that would be available to page.tpl.php?

The reason I ask is because I want to have custom page layout css files within a single theme, and the easiest way I can think of doing that is by making css files and putting them inside a folder named after the current theme, so that when the user changes the theme, it will load in the custom css layouts for that specific page within the current theme.

Thanks!

Comments

Heine’s picture

I'm not exactly sure what you're trying to achieve. But when you want to modify an existing template only by css, you can put a new style.css in a subfolder of the theme. Drupal will automatically detect this new style as a new theme.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

Dublin Drupaller’s picture

If you click through to this handbook page: http://drupal.org/node/46024

It explains how to insert unique BODY Classes & IDs for your pages in your page.tpl.php files, so you can pull up custom styles within your style sheets within the same theme.

An example application might be for adjusting a fixed width layout when you use the administrative options.

Using this snippet, when you go to to admin/themes, for example, you may use the following style hooks in your style sheet to control how the full page looks.

<body class="section-admin" id="page-admin-themes">

In your style sheet (the CSS file in your active theme folder), you simply add another line to change the layout when you click on the ADMINISTER menu:

.content { width="744px" }
.section-admin .content { width="100%" }

I hope that helps and the handbook page is easy to follow. It doesn't go into the detail of HOW it works..it's just a step by step.

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

arruk’s picture

node/46024 does not appear to exist

alonpeer’s picture

The global variable $theme_key gives you the name of your theme.
If you want more theme info, you can use the function list_themes() (defined in includes/theme.inc) to get a list of available themes, and then use the global variable $theme_key to get your them object like this:

global $theme_key;
$themes = list_themes();
$theme_object = $themes[$theme_key];

// print all the object fields
var_dump($theme_object);
vaab’s picture

Thanks, this helped me... ;) As I understand that using this variable could be a result of a badly thought solution, here's my case :

I want to add specific icons to each node depending on there types, but this must be themable, so I want to fetch icons in the "images/" in the theme directory first... then fallback on a default icon provided by the module.

To create the valid "img" tag, and fill its "src" attribute, I must access the path of the current path...

Is there a best way to achieve the same goals ?

phayes’s picture

If you need to access before themes are loaded.


$current_theme = variable_get('theme_default','none');

$themes = list_themes();
$theme_object = $themes[$current_theme];

// print all the object fields
var_dump($theme_object);

a6hiji7’s picture

If you need the path of the current theme then just use drupal_get_path('theme', 'theme_key'). See http://api.drupal.org/api/function/drupal_get_path/ .

cotasson’s picture

Can't you just use the path_to_theme() function, and from there infer the current theme ?

I was looking for a better solution, and ran across this thread : Just my two cents then...

ParisLiakos’s picture

global $theme;

or directly:

$GLOBALS['theme'];
SivaprasadC’s picture

Thanks