[wp-hackers] Themes support

Ryan Boren ryan at boren.nu
Tue Sep 14 08:59:13 UTC 2004


On Tue, 2004-09-14 at 09:03 +0100, Allan Mertner wrote:
> Hi Ryan,
> 
> >It's all in there.  I have Kubrick and some other things running as
> >themes.
> >  
> >
> I don't think it quite is. I downloaded and installed Kubrick (very nice 
> theme, btw!) and it uses a WP 1.2-style index.php where everything is in 
> that file; in 1.3, there is a nice separation of concerns.

Theme authors are free to organize their templates however they want.  I
have other themes that use separate templates for categories, posts,
pages, etc. and separate includes for the header, footer, and sidebar.

> I have created a test theme where the sidebar, header, footer etc. are 
> in separate files, like the new v1.3 index.php and associated files now 
> look for.  I would like the theme to not include index.php and just use 
> the default one, which should load the sub-files to plug in a new header 
> and footer and leave the rest in peace, for example. 

A theme must have a complete template.   If you're doing a stylesheet
only theme, you can pick up the template from another theme, but the
template must be complete.

> This is not currently possible, and doesn't work even if I copy the 
> default index.php into my theme. I imagine that this is how people will 
> try to make themes in the future: copy some or all of the default  files 
> and edit them.  The reason why it doesn't work is that all of the 
> "include" files are loaded from ABSPATH, which is always the root of 
> your installation and not a themes dir.
> 
> OTOH, I don't think it requires a lot of changes for it to work really 
> nicely.
> 
> Thoughts?

Don't use ABSPATH.  Make them relative.  I have the current default
template (index + header + footer + sidebar) and stylesheet working as a
theme just fine.

Once themes start to show up, themes will be created by copying other
themes.  If someone used only themes and ignored the default templates,
their index.php could be abbreviated to this:

<?php require('./wp-blog-header.php'); ?>

We could ship it like this if we also shipped a default theme in the
themes dir.  Wouldn't that surprise people?  What the hell happened to
my index? ;-)

I've moved my site layouts into the themes directory and left index.php
and wp-layout.css in their WordPress default forms.  This way upgrades
of the WordPress code don't disturb my templates or stylesheets.  Since
I never switch to the default theme, wp-layout.css is unused and
index.php is simply there to load wp-blog-header so that the template
redirect can be performed.

Oh, one thing that probably needs to be made theme aware is
comments_template().  I think that's the only missing piece of
infrastructure.

Ryan





More information about the hackers mailing list