0

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?

2
  • you most probably should be looking into the node templates
    – Jimajamma
    Commented Aug 19, 2013 at 16:20
  • Would that have any material differences from a page template?
    – Jack Ryan
    Commented Aug 19, 2013 at 16:23

5 Answers 5

1

It depends on what you want/need. Not only for content types, for theming generally; my suggestions:

  1. For little/cosmetic changes(font, color etc.) and basic layout settings you can use node-type-yourcontenttypename class and style with CSS.
  2. For moderate+ structural and visual needs you can use Views, Context, Panels etc. alone or combined(and CSS of course).
  3. For the things you can't achieve without dirtying your hands; you can create special template files for pages, nodes, block, views etc.
  4. 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.

0

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.

0

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.

0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.