What's the best way to theme a content type? Is there an effective way? Can I just use my page template, resave it with a different name and do it that way?
5 Answers
It depends on what you want/need. Not only for content types, for theming generally; my suggestions:
- For little/cosmetic changes(font, color etc.) and basic layout settings you can use node-type-yourcontenttypename class and style with CSS.
- For moderate+ structural and visual needs you can use Views, Context, Panels etc. alone or combined(and CSS of course).
- For the things you can't achieve without dirtying your hands; you can create special template files for pages, nodes, block, views etc.
- For the things you can't achieve with above ways; you can hack core, module, theme files. But this would be last and worst way to go.
You can do lot of things with 1, most of things with 1+2 and almost everything with 1+2+3.
The best way is to create a different template for each content type. For example, you would make a node--product.tpl.php template in your theme's template folder to theme all content with the "Product" content type. Once you flush your site's cache, all Product content will follow the new template, and all new Product nodes will follow it as well.
Visit this link- https://api.drupal.org/api/drupal/modules!node!node.tpl.php/7 . You can copy node.tpl.php into your theme folder and then modify the code to control the output.
There is couple ways/modules to do that:
If you dont want to code use Display Suite: https://drupal.org/project/ds (you can change fields markup, rearange them and put into regions)
OR
If you want only to change field markup us https://drupal.org/project/semantic_fields , and them rearange code them in node--[contenttypename].tpl.php
OR (my personal favourite)
Turn on Devel module. Put dsm($node) in node--[contenttypename].tpl.php - you'll see the node object and can reach for raw field values. Print them with your markup around.
Using Display Suite is my preferred method. https://drupal.org/project/ds
You can create multiple view modes for each content type. For each one, you can control the layout, which fields to display, and the markup for those fields. You can then choose which view mode to use when displaying them in Views. All of the Display Suite configuration is exportable, so it works well with the Features module.