User login

Reply to comment

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">';
}
?>

Reply

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.