I have a page--contenttype.tpl.php in a custom theme that displays a node exactly how I want it to display on its own node page. How do I make it so that the teaser for the node of that type displays the same as it displays in full view?

I want to add this in either template.php, page.tpl.php or page--contenttype.tpl.php of my custom theme but cannot figure out the best way of doing it

  • If you are using Views to construct these lists of teasers, you can use node--view--NAMEOFTHEVIEW.tpl.php – Jimajamma Oct 6 '14 at 18:57
  • I am not using views. This is a theme written from scratch that uses only the core apis – Emanegux Oct 6 '14 at 19:00
  • node.tpl.php can also be extended to node--TYPE.tpl.php and within you can use the $view_mode, $teaser and/or $page variables to modify behavior. See drupal.org/node/1089656 and api.drupal.org/api/drupal/modules%21node%21node.tpl.php/7 for lots more information. – Jimajamma Oct 6 '14 at 19:05

You can add template files in your template.php & then add files for them. In your case write something like this in your template.php -

function THEME_preprocess_node(&$vars) { //Replace THEME with your theme name.
  if($vars['view_mode'] == 'teaser') {
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['node']->type . '__teaser';   

After that, your TPL file for teaser would be in the format of node--[type]--teaser.tpl.php. Don't forget to clear your cache after you do this..

| 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.