path_to_theme

5 theme.inc path_to_theme()
6 theme.inc path_to_theme()
7 theme.inc path_to_theme()
8 theme.inc path_to_theme()

Return the path to the current themed element.

It can point to the active theme or the module handling a themed implementation. For example, when invoked within the scope of a theming call it will depend on where the theming function is handled. If implemented from a module, it will point to the module. If implemented from the active theme, it will point to the active theme. When called outside the scope of a theming call, it will always point to the active theme.

4 calls to path_to_theme()

File

includes/theme.inc, line 1121
The theme system, which controls the output of Drupal.

Code

function path_to_theme() {
  global $theme_path;

  if (!isset($theme_path)) {
    drupal_theme_initialize();
  }

  return $theme_path;
}

Comments

To unconditionally get the path to your theme…

…and not the themed element, use:

<?php
  drupal_get_path
('theme', 'THEME_NAME');
?>

The path returned with path_to_theme() depends on where and when it's called which can be hard to predict. It's usually fine in most cases but if you're getting unpredictable results use drupal_get_path().

thanks!

I was calling path_to_theme in block--system--main.tpl.php and for some reason it was giving me garland (I was sub-theming garland). drupal_get_path works much better.

Frontend theme

if you use different theme for the admin area you get that theme instead...

So, is there any way to get the path,or at least,the name of the current frontend theme and not the administration one?

To get the current front-end (default) theme

Try this:

$theme_path = drupal_get_path('theme', variable_get('theme_default', NULL));

It should return the path to the default theme. Handy when you have different front-end and back-end themes.

Pete

True Story! --^

Works. mishly++

Login or register to post comments