Skip to main content

How to Create Drupal Themes for Different Content Types and Pages

This article is for web-developers who are interested in creating their Drupal themes. It would tell you how to create themes for different content types. As a bonus, you’ll get know how to create theme for an individual page (the default theme will be used for other site pages). Let’s start!
Theme for content type

Usually a few content types are used for Drupal-based site. And every content type should have unique appearance. There is pretty simple solution for this.

Open folder containing the default theme for your site and create the following file there: node-{type}.tpl.php

where {type} – is name of the required content type.

View the folder. You will see node.tpl.php file there. It is the default file which defines the standard appearance of every content type.

Copy content of node.tpl.php to node-{type}.tpl.php and modify it according to your needs. From now, content of the specified content type will appear according to node-{type}.tpl.php.
Theme for page

Sometimes you may need to change theme for some page on your site (for example, http://site/my/page). And other pages should use the default theme.

Open the folder which contains theme for your site and create page-my-page.tpl.php file there. So, name of the created file must consist of page-{next_argument}-{next_argument}.tpl.php.

Than copy content of the default page.tpl.php file to page-my-page.tpl.php and make the desired changes.

Attention! You should use system URL for the page. Make sure that there are no aliases there.