Hi Guys lets learn how to make or create a simple, basic durpal theme from scratch .

It is easy to understand and apply the concept  on your projects  there are some important files which have to be added in your theme.

Most durpal theme will contain the following files

For example if my theme name is learnwebscripts then

  • learnwebscripts.info(ie your theme name and the extension .info)
  • style.css –The stylesheet that must be followed in your theme
  • page.tpl.php –The template of your theme
  • logo.png (remember it must to a .png file so that drupal can automatically add the logo to your theme)
  • page—front.tpl.php  – The separate theme you like to follow for your front page.
  • images directory
  • screenshot.png this shows a default preview of your them.
  • template.php etc and lots more

By default a .info file of your theme is more than enough to start your theme

You should add your default theme in sites/all/themes/learnwebscripts

What drupal does it scans the template files present in you directory if you do not have those files it automatically adds the files to your theme it is located in modules/system folder

So thats what drupal need from you.

To create a simple drupal theme just .info file is enough.

Lets learn in depth about these files

Now once this file is added activate your theme in appearance->and find your theme then click enable and set deafault once this is done then this is how your template looks

What should a durpal .info file should contain

name = learnwebscripts

description = learnwebscripts theme is designed by webkites.in

version = VERSION

core = 7.x

project = “learnwebscripts”

if you have a css file in your theme you should add the following code for example if you have two css files you should declare like this

stylesheets[all][] = style.css

stylesheets[all][] = settings.css

Each drupal theme is separated by regions for example if you theme has a header, footer, left sidebar, right sidebar each of them is a separate regions and you should assign those regions in the info file eg

regions[header] = Header

regions[leftsidebar] = Leftsidebar

regions[rightsidebar] = Rightsidebar

regions[footer] = Footer

Now each regions what you have assigned will automatically added to your theme you can find it in structure->blocks and all your theme regions will automatically be assigned over there.

page.tpl.php

This is the page where you should design your theme to call the regions which you have assigned you just need to add this code

Eg:if you want to call the header region just add

<?php if ($page['header']): ?>

<?php print render($page['header']); ?>

<?php endif; ?>

page—front.tpl.php

Suppose if you have a unique front page then you should design it over here.

Template.php

For example there are certain situation where you have to write conditions that a css should work only for a separate page it that case use this code

<?php

if (drupal_is_front_page()) {

drupal_add_css(drupal_get_path(‘theme’, learnwebscripts) . ‘/style.css’, array(‘group’ => CSS_THEME, ‘type’ => ‘file’));

}

?>

So all the conditions in your theme should be added here

This is how you create a simple , basic durpal theme  in my next tutorial i will help you regarding how to style your theme and control using css thanks for steeping to learnwebscripts.com cheers.