Drupal 6 has come on in leaps and bounds since I first had a look at it a few years ago. It’s now powering new projects i’m working on, including Shares.ie, Competitions.ie, and Ewine.ie. I’ve used the wonderful oDesk to outsource some of the work, and have a contractor integrating Keiths excellent css layout for Shares.ie into a Drupal 6 theme. Tonight, however, I thought i’d spend an evening multitasking by watching the excellent Munster-All Blacks match, whilst at the same time having a go at integrating Keiths Competitions.ie design into a Drupal theme myself.
It was actually surprisingly easy! One of the reasons I like Drupal is due to the development metholody behind it. There is a core base of code, which modules and themes can be built on top of. Instead of hacking away at core code when you’d like to change the layout of code or how it is rendered, Drupal has a cascading system of overrides which allow you to create copies of the templates or other elements you wish to override, and edit these to override the core templates (which still exist, untouched).
It’s a more foolproof way of ensuring if you run into difficulties, or you wish to upgrade the core code, it won’t get messy, and you’ll be able to debug quite quickly if anything horrible happens.
Anyway, creating a theme is as simple as this:
- Make a new folder for your custom theme, preferably in /sites/all/themes/custom/yournewthemename.
- Create a .info file and name it accordingly e.g. yourthemename.info – it defines the name of the theme, location and name of the stylesheets, any js elements, define areas for navigation areas, content blocks, and special functions (search box, logo, etc).
- Create a page.tpl.php file – this is your phptemplate file where the layout (or wrapper) of your site is defined. It’s easy to create, and well documented. This is also where you add in some quick code to render the content blocks and navigation areas you defined in the .info file.
- Add your style.css file – as mentioned above, you can call the file anything, but if you’ve not defined the name of your stylesheet in the .info file, Drupal presumes it’s called style.css.
- Log into your admin area, browse to the themes management area, and switch on your theme – it’s that easy!
Obviously, you’ll need to spend a bit of time fixing small layout issues if you’re a perfectionist, but you can have your basic theme ready in less than half an hour. To override elements like breadcrumb output and blocks output, you can just copy the .tpl files from a ready-made theme (zen is usually good!), place them in your new custom themes directory, and hack away.
Easy!