« back to folderblog
folderblogwiki

DoctypeSwitch

The basic idea behind this extension for is to enable it to serve it’s XHTML pages as application/xhtml+xml to those browsers that support it, while still supporting those browsers that don’t. The reasons for doing something like this are detailed in a W3C note on XHTML media types, which is given further clarification by Ian Hickson of Opera Software in his article on why serving XHTML as text/html is considered harmful.

The Folderblog MIME Type Server extension solves these issues by using the methods detailed in Neil Crosby’s XHTML MIME type article, which in turn is based on Simon Jessey’s article on how to serve XHTML correctly. Correctly validating XHTML 1.0 Strict or XHTML 1.1 is served as application/xhtml+xml using the XHTML 1.1 document type to those browsers that will support it, while those that don’t are served with text/html using the HTML 4.01 Strict document type (since XHTML is still read as tag soup if the browser can’t parse XML, which entirely relies on the browser’s error handling). Additionally, this extension ensures that the W3C validation service will still validate your pages against the preferred MIME and document type, no matter what browser is used.

Installation
Before you start, make sure that whatever Folderblog template you’re using will validate as XHTML 1.0 Strict using W3C’s validation service. Test a few of your pages to be certain of this (your main page, comments page and archive page would probably suffice). For this extension to work, XHTML 1.0 Transitional is not strict enough, as it supports several tags that are deprecated.

Installation for Folderblog 2.02
For this extension to work in Folderblog 2.02, you'll have to perform several hacks. Locate the template files named
template_com.php
,
template_main.php
and
template_menu.php
in your Folderblog directory. Open them up in your favourite editor, and look for the
!DOCTYPE
declaration and the
html
declaration. These will probably be the first two lines you’ll find there, and will look something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


You will need to delete both of these lines on all three of these files, so that nothing appears immediately before your
<head>
declaration. Save theses files and upload them to where you found them.

Now you'll have to locate and open up your
folderblog.php
file in your favourite editor, and find this statement on line 136:

if(strlen(trim($url))&&$url!="http://") $name="<a href=\"$url\" target=\"_blank\">$name</a>";

The
target="_blank"
attribute is depricated in XHTML 1.0 Strict (and thus XHTML 1.1 as well), so you’ll need to delete it, leaving you with this:

if(strlen(trim($url))&&$url!="http://") $name="<a href=\"$url\">$name</a>";

Note that this link gets written to those text files named
yourimagename_com.txt
in your comments directory, so if you’re doing this trick on an old working version of Folderblog 2.02, then you’ll have to go through those files and delete this attribute from each of them.

Next, you'll need to replace line 6 with this line:

error_reporting(0);

This turns off error reporting, which is always a wise thing to do once any script is tested and goes live, as we don’t want to reveal server file structures to users if something goes wrong.

Finally, add this line after line 12:

include('fb_mimetype.php');

Once you’re happy with that, save your
folderblog.php
file and upload it to where you found it.

Now you can download the Folderblog MIME Type Server extension, and then upload it to the same location. If everything was done correctly, your Folderblog site should now serve itself with the correct MIME and document type.

Installation for Folderblog 3 (beta)
Folderblog 3 supports the use of extensions, so you won’t need to perform any hacks. However, you will have to edit the template files named
template_archives.php
,
template_main.php
and
template_comments.php
in your Folderblog directory, and delete the
!DOCTYPE
declaration and the
html
declaration from each of them, as described above.

Now you can download the Folderblog MIME Type Server extension, and then upload it to the
/extensions
directory. If everything was done correctly, your Folderblog site should now serve itself with the correct MIME and document type.

-- Elwing
Home  Index  Recent Changes  folderblog
Last edited February 23, 2008 at 10:51pm.(edit this entry)