- CCK form field changes using Drupal's hook_form_alter don't work? Use #after_build
- Views query substitutions in Drupal 6
- Should you be building your next website in Drupal?
- How to add Zoopy video to your Drupal site using CCK and the Embedded Media Field module
- My state of Drupal, today, 18 March 2009
- Drupal Johannesburg 11 March meetup notes
- Quick Drupal setup using Acquia's DAMP stack
- Drupal conference 2009 videos available on the Internet Archive
- Drupal 500 Internal Server Error on shared hosting
- The case for Drupal
How to get the path to your theme in your drupal template
Instead of hard coding your theme path into your drupal theme templates, it's better to use some built in drupal functions or template variables:
- Use the $directory variable which will be available in your .tpl.php files
- Use the path_to_theme() function - this provides the same output as the $directory variable
- Use the base_path() function which will give you the url to the root of your site.
I always use absolute references, for example:
 . $directory;?>/images/site/header/logo.jpg)
this includes the domain name and then the theme path.
Update:
Sometimes in a custom module I need the absolute path (not the url) and I've found using the function realpath() helps, for example, say I want to get the path to the files directory:
realpath(".").'/files/'
This will output /usr/var/www/whatever/files/.
- Wordpress category:
