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

Thanks!

Comments

WorldFallz’s picture

_
Care about the future of the Drupal.org forums? Please join our conversation and show support for improving the forums infrastructure.

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 ;-)

_
Care about the future of the Drupal.org forums? Please join our conversation and show support for improving the forums infrastructure.

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

<?php
      drupal_get_path
('theme',$GLOBALS['theme']);
?>
sharif.elshobkshy’s picture

drupal_get_path('theme',$GLOBALS['theme'])

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;
path_to_theme();

Take care.
Sharif.