Path to theme

Looking for the drupal path to your current theme? It can be helpful if you're making a theme and, for a change, you want to link directly to

print theme('stylesheet_import', base_path() . path_to_theme() ."/modules.css");

For our purposes, something like:

<img src="<?php echo base_path() . path_to_theme() . "/sample.png"; ?>" />

Now I'm not sure that "." in echo will work. Feel free to test it out for us!

UPDATE: To get print an image that is in your theme by getting its path, Agaric thinks the recommended approach is

<?php
print '<img src="'. path_to_theme() .'/images/picture.jpg" />';
?>

Or the Dan Hakimzadeh method of using imagecache, and therefore the files directory, from your theme:

<?php
$primaryimagexists
= $node->node_data_field_user_picture_field_user_picture_fid;
if (
$primaryimagexists != 0) {
  print
$field_user_picture_fid;
}
else {
  print
'<img src="/sites/example.com/files/imagecache/userpic_thumb/sites/example.com/files/images/LC-Sun.jpg">';
}
?>

by Benjamin Melançon
Posted on Mon, 2007-02-12 23:31
in
Actually, the current official Agaric way

Should look something like this, to call for instance your custom logo, in an images folder in your theme directory, directly from your theme's page template file (page.tpl.php):

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

[Note: comment older than update above.]

Posted by Benjamin Melançon on Fri, 2007-02-23 08:21
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
  _____   _____   _      __     __  _____ 
| ___| |___ / | | \ \ / / |_ _|
| |_ |_ \ | | \ \ / / | |
| _| ___) | | |___ \ V / | |
|_| |____/ |_____| \_/ |_|
Enter the code depicted in ASCII art style.