How to create Drupal 7 theme

Create a drupal 7 theme is not  rocket science. You, just, have to follow few things:-

  1. You have to make  a folder in /sites/all/themes/ .  if your theme name will be “example” then make a folder names as “example”  and path will become /sites/all/themes/example
  2. Now, make  example.info  file in you example folder and write few lines of code
    name = Example Theme
    description = Any Description.
    version = 1.0
    core = 7.x

    These four lines must be written.
    you can also include css file(s) as, you can add as many as css you want
    stylesheets[all][] = style.css
    stylesheets[all][] = settings.css
    you can define regions ( means area ) you can change regions according to you design
    regions[header] = Header
    regions[leftsidebar] = Left sidebar
    regions[rightsidebar] = Right sidebar
    regions[footer] = Footer
    and final info file becomes

    name = Example Theme
    description = Any Description.
    version = 1.0
    core = 7.x
    stylesheets[all][] = style.css
    stylesheets[all][] = settings.cssregions[header] = Header
    regions[leftsidebar] = Left sidebar
    regions[content] = Center
    regions[rightsidebar] = Right sidebar
    regions[footer] = Footer

    Drupal 7 Region layout

    Drupal 7 Region layout

  3. make a template.php file if you want to write any function but most of newbie did not write any function so leave it blank. But you have to place this file for sure.
  4. Take screenshot of you file resize it to 250X150 pixel and place it  theme directory rename as screenshot.png again this  file must be placed.
  5. Now, You have to make  “templates”  folder in /sites/all/themes/example  and path will become /sites/all/themes/example/templates
  6. You have to make page.tpl.php and node.tpl.php files in  templates folder.
  7. Theme variable for page.tpl.php are http://api.drupal.org/api/drupal/modules!system!page.tpl.php/7

File structure will become as

Drupal 7 theme file structure

Drupal 7 theme file structure

 

This entry was posted in Development and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.