Hi all!

I'm new at Drupal, coming from the PHP framework world, and I'm having some problems understanding the the template hierarchy in Drupal 7.

I've created a template called 'node--article.tpl.php' and can style my single article nodes. The problem is that this affects the front page as well. I want to style the node list different then when displaying single nodes. How can I do this?

/ Tobias

Comments

sign’s picture

First, you can show/hide fields in the content type display fields settings, set different view mode for teaser and/or default/full-node view

or there is a variable $teaser available in node.tpl.php (node--article.tpl.php, etc...) which you can use to find out if the node is being displayed in teaser or full mode

 * - $teaser: Flag for the teaser state (shortcut for $view_mode == 'teaser').

or you can create a new template file suggestion for teaser such as node--article--teaser.tpl.php in preprocess function (in template.php)

function mytheme_preprocess_node(&$variables) {
  // add a new template suggestion for teasers
  if ($variables['view_mode'] == 'teaser') {
    $variables['theme_hook_suggestions'][] = 'node__article__teaser';
  }
}