0

I have used given below code for node--[content_type].tpl.php (default) template file

function MYMODULE_theme($existing, $type, $theme, $path) {
  return array(
    'node__NODETYPE' => array(
      'render element' => 'content',
      'base hook' => 'node',
      'template' => 'node--NODETYPE',
      'path' => drupal_get_path('module', 'MYMODULE') . '/templates',
    ),
  );
}

but I don't know how to call my node--[content_type]--[view_mode].tpl.php

Please suggest.

  • "If the question is about code you wrote, for which you want to write better code, or you want to understand why it doesn't work, show the code you are using, or the part of the code that is relevant for the question." - see Help Center – Mołot Jun 17 '15 at 12:34
1

You can use node--[content_type].tpl.php for changing the output for view mode.

if ($teaser) { 
  // node is being displayed as a teaser

} else { 
  //all other cases  
}
| improve this answer | |
0

in your theme template.php on function THEME_NAME_preprocess_node(&$variables) put the

$variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . $variables['view_mode'];

then on the theme copy node.tpl.php to node--article--full.tpl.php (for example) and edit as you want.

Now, you can have template for each content type and for each view mode.

| improve this answer | |

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.