I'm using zen as my parent theme and for some reason path_to_theme() is suddenly printing /sites/all/themes/zen instead of the subtheme /sites/all/themes/<mytheme>. What's even more confusing is that it's only happening when node/12 is being displayed.

Could this code have something to do with it?

    if($vars['node']->nid == 12) {
        $vars['is_request_quote'] = true;

I use the variable $is_request_quote to change the layout in page.tpl.php. I do this through <?php elseif( $is_request_quote ) : ?> -New layout here- <?php endif; ?>. Could that be the one affecting it?

  • Where do you call path_to_theme()?
    – apaderno
    Commented Aug 22, 2011 at 18:54
  • Inside node--12.tpl.php.
    – enchance
    Commented Aug 22, 2011 at 19:02

2 Answers 2


I had this problem too. Solution here, applied to node instead of page, worked for me: copy node.tpl.php to your custom theme templates directory. Once I did that, path_to_theme() behaved correctly.


I found the answer! It's probably not the best one so feel free to challenge. After several tests, I found out that path_to_theme() correctly points to the subtheme in page.tpl.php but when you use it in node.tpl.php it suddenly points to the parent theme (zen).

My answer is a 2 step process starting with creating the variable which stores the path I want:

function themename_preprocess(&$vars, $hook){
    $vars['THEMEPATH'] = base_path() . path_to_theme(); //points to subtheme

then to make sure it works in nodes, enable the following function to make it available in node.tpl.php. There doesn't need to be anything inside it, as long as the function gets declared in your template.php file.

function themename_preprocess_node(&$vars, $hook){
    // Put anything here or leave it blank

After doing so, voila! You can now use $THEMEPATH in both nodes and pages.

  • Wouldn't work for me, not in html.tpl.php that is. Commented Jan 2, 2016 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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