I’ve been playing with the WP templates and I like how for instance a “header.php” placed in the WP dir will automatically overrule “wp-header.php.” This is going to make custom templating much easier, kudos!
However, here’s my take on how to respectfully chop up index.php.
1) If it’s going to be made so easy to drop in your own header.php replacement, we’re definately are going to need to be able to drop in a “body.php” replacement. The thinking here is that you don’t really want to replace index.php as a template author.
If you can make a set of template drop-ins (header.php, body.php, footer.php, sidebar.php, layout.css), you want to offer the enduser an easy option to roll back. If you have replaced the index.php that is going to be slightly more difficult. If the enduser just has to remove the files you have added to return to the vanilla WP install, that’s going to that much easier.
Eventually I can see a theme manager for WP that will drop a set of template files into the WP dir for the user, but will also remove them again when the user wants to roll back or install another template set.
2) The way the template files are currently cut up goes against my neatness grain. What I mean is that index.php itself should be a well formed HTML file. Right now the doctype and the html tag reside in the wp-header.php file, as does the body tag and some assorted divs.
While this works, it’s far from neat and organized, so I propose the following (simplified) layout for the index.php file:
<?php require for wp-blog-header.php>
<?php include wp-header.php>
<?php include wp-body.php>
As you can see, the minimal (theoretical) form of a html page is retained: it has got the html tags around and the body tags go around the body. What is actually inside those tags is up to the included files.
3) As you can also see, the index.php doesn’t call wp-footer.php or wp-sidebar.php. These are called recursively from wp-body.php: wp-body.php would look like this:
<?php include wp-title.php>
<?php include wp-content.php>
<?php include wp-sidebar.php>
<?php include wp-footer.php>
I can see how this last recursion might appear superfluous, but by making body.php call a number of content ‘modules’, you offer the template author the possibility of not including some of the standard modules.
Say you would put those 4 modules straight into the index.php and I wanted to create a design without a sidebar, I would have to go into the CSS and set the sidebar div to display: none, while bloating my html with stuff that’s not getting displayed. If I have the possibility of creating a drop-in replacement for the body.php, then I can choose to omit a call to the sidebar.php in the first place.
4) As a visual illustration, here’s a tree-view of the proposed structure for the vanilla WP layout. All items, except the index.php itself, can be replaced by drop-ins by the template author:
Let me know what you think 🙂
- You must be logged in to reply to this topic.