Saturday 17 December 2011

Drupal 7 theme structure

I decided to create an explanatory graphic that ilustrate the different theming portions of Drupal 7 and how to access and modify them. This is not a theming tutorial but a quick guide to see the different parts of a Drupal theme.
Notes:
  1. Page.tpl.php is basically where your main layout is. If you are starting from an HTML file, you can do the same as me and rename it to page.tpl.php and start populating the necessary elements. You can see which elements here.

    This page needs to contain everything that goes inside the body (you shouldn't add the <body> tags here).
  2. In Drupal 7 everything that holds content is a region, even the region that holds the "content" block.
  3. Node.tpl.php is the themed representation of a content entry and when listing content this file will be called multiple times, one after another.
  4. A block is just a piece of content that can be plain HTML or be generated from a module. (Like the Login block)
  5. A region is what holds multiple blocks. These are the defined in the .info file and called in page.tpl.php
Worth mentioning:
  • When creating the theme.info file, starting from Drupal 7 you need a region called "content" or the theme will show up as incompatible in Appearance settings.
  • I'm not including all the TPL files but the ones I use the most.

No comments:

Post a Comment