When I print the content of $directory in my theme's page--front.tpl.php, it outputs "modules/system."

This is not I want; I want to output "sites/all/mytheme/images/…." How can I do it?


if you want to find the folder of your theme you have to use something like this:

<?php echo drupal_get_path('theme','your_theme').'/images/whateverfile.ext'; ?>
  • you're right. thank you. but why echo $directory can't output the theme directory in page--front.tpl.php? but can in page.tpl.php. – enjoylife May 18 '11 at 7:30
  • 2
    the $directory variable is done in template_preprocess() which uses the path_to_theme() function. so there is your answer. – cmos May 18 '11 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.