1

In my site I have 10-15 content types that have the exact same node template layout. Like node--productone.tpl.php, node--producttwo.tpl.php etc...

How can i create one node tpl files for that similar type of content types?

1

Yes you can. Here is the example:

function YOURTHEMENAME_preprocess_node(&$variables) {
  if ($variables['node']) {
    $node = $variables['node'];
    switch ( $node->type ) {
      case 'type1':  // Replace with your actual content types
      case 'type2':
      case 'type3':
      // looks for node--common.tpl.php in your theme directory
      $variables['theme_hook_suggestion'] = 'node__common';
      break;
    }
  }
}

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.