I'm finding lots of examples for theming the node template of a content type, but I can't figure out how to use a template from my module as the page template for a custom node type.

1 Answer 1


page.tpl.php doesn't know, by itself, anything about node types so you'll have to make your module preprocess the page with hook_preprocess_HOOK() to add an alternative theme hook suggestion.

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

Once done, you can have your module evoke hook_theme() to advertise processing for your custom page node type template and its location. For example:

 * Implements hook_theme().
function MYMODULE_theme($existing, $type, $theme, $path) {
  $theme = array();
  $theme['page__mynodetype'] = array(
    'path' => drupal_get_path('module', 'MYMODULE') . '/templates',
    'template' => 'page--mynodetype',
  return $theme;

When the module is enabled (and theme registry cache cleared), the theme engine will look for page--mynodetype.tpl.php within the templates directory of your module.

  • I'm not looking for a node template, but rather a page template.
    – Joren
    Oct 14, 2016 at 17:11
  • Updated, same idea but with an additional function to make page templates aware of node types.
    – Shawn Conn
    Oct 15, 2016 at 0:04

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.