Different style when listing nodes and displaying a single node
Pergunta
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?
Solução
Berdir's suggestion (coolest imho):
you can even provide custom template suggestions based on the view mode. See for example drupal.org/node/223440 and bri-space.com/content/creating-drupal-template-suggestions
Also within node-article.tpl.php you can inspect $view_mode
and decide what to do. You could either include the logic of both templates in the one file, or create different templates and include the appropriate one based on the value of $view_mode
You might also find Display suite interesting.
Outras dicas
By using Views module, you can create custom displays of node lists (and many other things). This is your master page builder tool for Drupal. http://drupal.org/project/views
With views, you can define the type of view (normal node teaser view, list using select fields, etc.), filters (e.g., show only article nodes, not other node types), sorting order, and so on. Views also has this power for listing users, comments, taxonomy… And you can define these views for pages (where the view you define is the content in the main content area), blocks that appear on any page, and even RSS feeds.