Drupal – Create a Garland Subtheme

I would like to edit some PHP and PHP template files but i dun want to modify those files in the default Garland theme. So i’d better create a Garland Subtheme which inherits those files from the Garland theme as well as i could create my own PHP and PHP template files under the subtheme folder for overriding the default.

Actually i am not very familiar with the theme architecture of Drupal, but the following example works as i expected.

1. Create a folder name as garland_subtheme under <drupal_root>/sites/all/themes.
 

2. Create the <drupal_root>/sites/all/themes/garland_subtheme/garland_subtheme.info

name = Garland Subtheme
description = A subtheme of Garland
core = 6.x
base theme = garland

 

3. Copy the color folder to the garland_subtheme folder such that you set a different theme color from the parent Garland theme

  • cp -R <drupal_root>/themes/garland/color ./

 

4. Create the following symbolic links under the garland_subtheme folder

  • ln -s <drupal_root>/themes/garland/images images
  • ln -s <drupal_root>/themes/garland/style.css style.css
  • ln -s <drupal_root>/themes/garland/logo.png logo.png

 

5. Also create the the template.php under the garland_subtheme folder
template.php

<?php
/* Print a text before loading the page */
function garland_subtheme_preprocess_page(&$vars) {
        print("ykyuen.wordpress.com");
}

 

6. Set the Drupal theme to Garland Subtheme and see what you get.

    

Done =)

Reference:

4 thoughts on “Drupal – Create a Garland Subtheme”

  1. You have the basic idea, but I would suggest two things to do differently:

    1. Do not subtheme Garland. If you are ready to do a full theme, you should start with a base theme that has been designed to be used this way. I use Zen 2, but there’s a full list here http://mogdesign.eu/blog/19-base-themes-for-drupal/ (a little outdated). Many of the most popular themes on Drupal.org are popular because they work well as base themes. http://drupal.org/project/themes

    2. Don’t create symbolic links. If you ever want to contribute your theme to the community or copy it to another site, this is a needless risk for complication. Just copy the files instead!

    Like

    1. Thanks for your suggestions. i am quite new to drupal and probably i have used an improper method in this articles. =P

      Like

    1. It is not really a good way to sub theme the default Garland theme. It is better to use some base theme which is for specially for subtheming.

      As suggested by bangpound, you could try the Zen theme. i usually use Fusion.

      Reference:

      Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.