In hook_preprocess($vars)
create a new variable called path_to_theme
in $vars by including the following (where $hook
is page, node, block etc)
function mymodule_preprocess(&$vars, $hook) {
$vars['path_to_theme'] = base_path().path_to_theme();
}
Now in virtually all of your theme's template you can use the variable $path_to_theme
and it will be the contents of base_path().path_to_theme()
Note, that you can put this in a custom module, or replace mymodule
with the name of your theme and you can place it in your theme's template.php
You can use node, page, and other "hook" specific preprocess functions if you only wish to add this variable to specific content of your site.
There are many options for preprocessing nodes, pages etc. which can be read up in:
Setting up variables for use in a template (preprocess and process functions)
Also be sure to read up on the Default baseline variables such as:
$directory The theme path relative to
the base install. example:
"sites/all/themes/myTheme"
$path = $base_url . '/' . path_to_theme()
?