I'd like to avoid breaking my theme paths eg. ( /sites/all/themes/currenttheme ) by using a php variable like $directory/currenttheme to get the path for the current theme running. I know I saw this somewhere as recommended practice but I can't seem to figure out the proper syntax to do it.

Can anyone point me to the right page or tell me the syntax for it?

The problem is when I moved my theme from a local test site to remote multiinstallation of drupal, all the theme paths to my image directory broke



WorldFallz’s picture

PMorris’s picture

Brilliant! I was searching all over for it but I kept putting in the wrong search terms I guess. Cheers

WorldFallz’s picture

welcome ;-)

PMorris’s picture

In my page-front.tpl.php, here's an example of how I ended up doing my theme's logo so the path doesn't break when I move the theme around:

<img src="/<?php print path_to_theme(); ?>/images/logo.gif" alt="<?php print t('Home') ?>" id="logo" />

norio’s picture

You can save yourself a few keypresses and a function call by using this instead:

<img src="/<?php echo $directory; ?>/images/logo.gif" alt="<?php print t('Home') ?>" id="logo" />
jackenmail’s picture

sharif.elshobkshy’s picture


Although you can use what Drupal offers and find information about the current theme from the global variables or functions.

global $theme;
global $theme_path;

Take care.