Tuesday, February 7. 2006
This article is all about porting a Wordpress theme over to Serendipity blog. The theme we're going to be porting is dusk, available from
beccary.com. This theme is an attractive moody theme particulalry liked for its purple and black background. The only description I could think of to describe this theme is 'gothic lace'. The inspiration for this article, which will become a short series on porting and then customising a Wordpress theme, came from discussions over at the
serendipity forums.
After downloading the dusk zipfile, unzip it to your serendipity templates folder. Next, we need serendipity to recognise the new theme, so copy the 'info.txt' file from any other theme into your new dusk folder. Open this file and edit the details so that the theme name is now dusk. You can safely leave the other fields the same and serendipity will happily use your new theme, but if you plan to share your theme then go ahead and change the author name and creation date as well.
Page Structure
The first secret to porting the dusk theme is that it uses a css-only two column layout. Viewing the wordpress theme in a browser shows the following basic structure;
<div id="wrapper">
<div id="header">
<div id="title">
</div>
</div>
<div id="content">
<div class="post">
</div>
</div>
<div id="sidebar">
</div>
<div id="footer">
</div>
</div>
We need to replicate this structure within serendipity for the theme to work as it was designed to, so the following is how the structure part of your index.tpl will look. If you're not comfortable editing smarty template files yet, download the zipfile for this article and take a look at my index.tpl. Download
dusk-part1.zip.
<div id="wrapper">
<div id="header">
<div id="title">
<h1><a href="{$serendipityBaseURL}">{$head_title|@default:$blogTitle}</a></h1>
<h2>{$head_subtitle|@default:$blogDescription}</h2>
</div>
</div>
<div id="content"><div class="post">{$CONTENT}</div></div>
<div id="sidebar">
{serendipity_printSidebar side="right"}
{serendipity_printSidebar side="left"}
</div>
<div id="footer">
Design Downloaded from <a href="http://beccary.com" title="Beccary">beccary.com</a> | Ported to <a href="http://www.s9y.org">Serendipity</a> by <a href="http://www.carlgalloway.com">Carl</a>
</div>
</div>
Getting the background images to work
Our next step must be getting the images to work, because these are the main reason for selecting this theme. Luckily all of the images are referenced from within the stylesheet as background images. To allow serendipity to use them we need to do a couple of things.
First, rename the images folder from 'images' to 'img'. You need to do this because serendipity expects all images to be located in this folder, and having separate image folders for background images and serendipity specific images doesn't make sense.
Having renamed the images folder, open the stylesheet 'style.css' in your favourite text editor. You need to change the path of every background image so that serendipity can find the it. As an example, the body style has the following background;
background: #556777 url(images/bg.gif) repeat-x;
and this needs to be changed to;
background: #556777 url({TEMPLATE_PATH}img/bg.gif) repeat-x;
The {TEMPLATE_PATH} is the smarty variable used to let serendipity know the path to the img folder. Now go ahead and change every other background style that has a background image. There are only five in total, so this shouldn't take too long.
Using the Theme
Congratulations, you have successfully begun to port your first Wordpress theme. Take a look at your new theme in your browser, you'll notice of course there are many differences between Wordpress and Serendipity, and your theme won't yet look like a serendipity theme. In fact we are not finished customising this theme to be used by serendipity.
In my next article we'll rename the styles to comply with serendipity conventions, and then customise the title, entries and comments for this theme. Feel free to comment below so that others can benefit from your experiences.
Judebert said,
Tuesday, February 7. 2006 at 23:13 (Reply)
All in all, it's still a good idea to rename, but it's not really required.
Carl said,
Tuesday, February 7. 2006 at 23:25 (Reply)
Secondly, if you plan to modify some s9y specific images such as the feed icon 'xml.gif', or the calendar arrows as judebert says, they will need to be included in a folder named img. I personally prefer a single image folder, and since s9y expects its own images to be in a folder named 'img', this is what I use for theme images.
Carl
Hokey said,
Wednesday, February 8. 2006 at 09:21 (Reply)
?rn said,
Sunday, February 12. 2006 at 05:39 (Reply)
Keep up the good work.
Cheers.