Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By sandelius on
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
First, you can show/hide
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
or you can create a new template file suggestion for teaser such as node--article--teaser.tpl.php in preprocess function (in template.php)
My personal blog | twitter:@sotak