1

So I am new to Drupal and I am trying to create a new theme for a site. I am trying to create a page template for a specific custom content type. Research has led me to adding this to my template.php file:

function yourthemename_preprocess_page(&$vars) {
  if (isset($vars['node']->type)) {
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}

However, it is not working. I know the template.php file itself is being pickup up because a simple echo test works, but putting one in the function above does not fire. So I have to assume this function is not being called. I changed the 'yourthemename' to what I think is my theme's machine name. The folder name and .info name is FWMurphy. I tried that and fwmurphy and neither worked. I am stumped.

  • 2
    Use the exact case. Also did you clear your cache ?? – junedkazi Oct 10 '12 at 17:19
  • 1
    Btw, avoid using different case in theme/module names. – Aram Boyajyan Oct 10 '12 at 17:50
  • Still not working – BobbyDank Oct 10 '12 at 19:14
2

In your instance the hook should be (based on what you said your theme name is):

function FWMurphy_preprocess_page(&$vars) {
  if (isset($vars['node']->type)) {
    $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
  }
}

After you implement that, clear the drupal cache. For drupal to pickup your page--{node type}.tpl.php , you need to make sure your theme also contains a default page.tpl.php

  • Still not working. Like I said. Its like the function itself is never being fired. – BobbyDank Oct 11 '12 at 15:58
1

Okay. I ended up figuring out what was wrong. Given what I needed done and the info given here, there is no way anyone could have helped me with this, so sorry and thank you to all who tried.

Come to find out my .info file was named wrong. It was named theme.info instead of fwmurphy.info so it was throwing off the machine readable name for my theme. Once I renamed it and replied the theme, everything worked as it should.

Again thanks everyone.

  • 1
    Without proper information nobody can help you. Nobody can guess but can help only by given description of yours. I don't find any wrong with answer below.. – RajeevK May 29 '13 at 10:36

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.