Creating a zen subtheme in drupal 6 with ssh and vi
This tutorial assumes you have ssh access to your site (or are local) and can use wget and tar. If you already have zen installed and just want to make a subtheme, skip to secion 2.
Secion 1- Installing Zen
SSH into your site, cd to /path/to/drupal/sites/all/themes
If you haven't installed any custom themes you will need to make the themes folder:
cd /path/to/drupal/sites/all
mkdir themes
Once you're in, in a browser go to http://drupal.org/project/zen and right click the version of zen, and copy link location (as I'm writing this I used http://ftp.drupal.org/files/projects/zen-6.x-1.x-dev.tar.gz)
wget http://ftp.drupal.org/files/projects/zen-6.x-1.x-dev.tar.gz
tar -xf zen-6.x-1.x-dev.tar.gz
rm zen-6.x-1.x-dev.tar.gz
Note: If you get an error try tar -xzf
Congrats, zen is installed. You will need to go to http://yoursite.com.com/admin/build/themes to enable it, but you should wait until your subtheme is ready.
Section 2- Making the subtheme
Zen is meant to modified. The safest way of modifying a theme is make a sub-theme, they even give you a nice little starter kit. Once you have a sub-theme you can update zen freely without worrying about losing your customizations.
You should still be in sites/all/themes at this point, so
mkdir my_sub_theme
cp zen/STARTERKIT/* my_sub_theme
cd my_sub_theme
now you have created a directory for your subtheme, copied the starter kit into it and moved to that directory.
Now you need to fix the STARTERKIT.info file
mv STARTERKIT.info my_sub_theme.info
vi my_sub_theme.info
Now if you aren't familiar with vi (pronounced VEE-EYE) it can be an intimidating text editor, but its always available and really powerful so its good to know. You only need a few commands here.
Press 'i' - this will bring you into 'insert' mode (and out of command mode) which will allow you to edit the text like you normally would. Where it says
name = Zen Theme...
description = Read the online docs...
Change it to whatever you want. When you are done, press escape and type ':wq' (without the quotes).
Pressing i brings you into edit mode, pressing esc brings you back into command mode. while in command mode pressing 'x' deletes a single character. :wq basically says this is a command, write this file and quit. If you mess up, press :q! to exit without saving and try again
Sweet. Next, you need to fix your template.php and theme-settings.php files
vi template.php
..
vi theme-settings.php
Your job in here is to replace every instance of STARTERKIT with my_sub_theme. Fortunately vi provides an easy way to do this. You are already in command mode so type:
:%s/STARTERKIT/my_sub_theme/g
press enter, then :wq
Repeat for theme-settings.php.
Depending on whether or not you want a liquid or fixed width for your theme you need to copy the corresponding css file into my_sub_theme
cp ../zen/zen/layout-fixed.css layout.css
or
cp ../zen/zen/layout-liquid.css layout.css
Copy the zen style sheet to your folder
cp ../zen/zen/zen.css my_sub_theme.css
Congratulations! You're done. Log into admin/build/themes as administer and enable your sub-theme.
Notes:
- if you want to modify any of the other style sheets in the zen folder, copy them to my_sub_theme and uncomment them from your my_sub_theme.info (remove the preceding semi-colon)
- If you want to modify any of the tpl files (which you probably do) copy them to my_sub_theme (
cp ../zen/zen/page.tpl.php) first - Even if you want to leave the page.tpl.php or node.tpl.php the same and only want to get at specific pages or content type with files like page-23.tpl.php or node-story.tpl.php you still need to copy the corresponding parent file (node.tpl.php and/or page.tpl.php) into your my_sub_theme directory.