I want to have a custom template for pages. WordPress has template selection feature for Pages or Posts. Is that possible for Drupal?

  • Which Drupal? 6/7 ?
    – niksmac
    Apr 20, 2012 at 7:18
  • Drupal 7, Here i want a single template assign to some of pages. like Wordpress have defalut page, showcase page, sidebar page.
    – useCase
    Apr 20, 2012 at 7:29
  • Add 7 tag to your Question. Also see my answer.
    – niksmac
    Apr 20, 2012 at 7:30
  • Here i need, Suppose i create a Custom template name "page--twocolumn.tpl.php" and that template assign to some different pages. like node-7, node-8 and node-3 etc.
    – useCase
    Apr 20, 2012 at 7:40
  • No Of course not.
    – niksmac
    Apr 20, 2012 at 8:19

4 Answers 4


See here Drupal 7 Theme Hook Suggestions

For nodes You can use

    base template: node.tpl.php
    Theme hook suggestions are made based on these factors, 
listed from the most specific template to the least. 
Drupal will use the most specific template it finds:


Also Drupal 6 Template Suggestions

To use same tpl for multiple pages you need to use theme_preprocess_node Like

function theme_preprocess_node(&$vars, $hook) {
  $node = $vars['node'];
  if(in_array($node->nid), $myuids)
   $vars['template_file'] = 'your_template_file';

Take a look at Panelizer. It allows you to use Panels for content types, and you can define different layouts, content, contexts, etc. on a per node basis.

In my opinion, this approach is much easier to maintain than having a bunch of separate template files in your theme.

  1. Create a MYMODULE module;

Put the following code:

function MYMODULE_theme($existing, $type, $theme, $path) {
  $theme = array();
  $theme['TEST_NAME'] = array(
    'template' => 'TEMPLATE-NAME',
    'path' => drupal_get_path('module', 'MYMODULE'),
  return $theme;
  1. Create a file TEMPLATE-NAME.tpl.php in the module folder;

  2. Output it in places you wish with the code:

    theme('TEST_NAME', $vars);

Take also a look at the Theme Guide and the Core templates.

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.