Ferio
April 21st, 2006, 10:37 PM
Hi, I've got a blog at http://www.tecniferio.com; I created it using http://www.textpattern.com, which is a CMS very similar to WordPress. The point is that I'm using XHTML 1.1, and I'm seeing everywhere that it must (as specified by W3C) be served with "application/xhtml+xml" MIME type.
Since TextPattern is a PHP-based CMS, I've tried to add
if ((isset($_SERVER["HTTP_ACCEPT"]) and
stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) or
stristr($_SERVER["HTTP_USER_AGENT"], "W3C_Validator") )
{
header("Content-type: application/xhtml+xml");
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
}
else
{
header("Content-type: text/html; charset=utf-8");
}
at the beginning of my index.php (as stated in several pages I've seen), what will make my page be served as "application/xhtml+xml" to web browsers that support it, and "text/html" to the ones that don't (mainly IE). Anyway, I can't get it to work, and since I have no idea on PHP, I'm not sure about what I'm not doing well.
My index.php is:
<?php
/*
$HeadURL: http://svn.textpattern.com/development/4.0/index.php $
$LastChangedRevision: 804 $
*/
// Make sure we display all errors that occur during initialization
error_reporting(E_ALL);
@ini_set("display_errors","1");
if (@ini_get('register_globals'))
foreach ( $_REQUEST as $name => $value )
unset($$name);
define("txpinterface", "public");
// Use buffering to ensure bogus whitespace in config.php is ignored
ob_start(NULL, 2048);
$here = dirname(__FILE__);
include './textpattern/config.php';
ob_end_clean();
if (!isset($txpcfg['txpath']) ) {
header('Status: 503 Service Unavailable'); header('HTTP/1.0 503 Service Unavailable');
exit('config.php is not ok or not found. If you would like to install, go to [/subdir]/textpattern/setup/');
}
include $txpcfg['txpath'].'/publish.php';
textpattern();
?>
and the beginning of the content of my page that I typed using TextPattern is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
<base href="<txp:link_to_home />" />
<link rel="stylesheet" href="<txp:css />" type="text/css" media="screen" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
I'm giving all this information because I'm not sure about where's what I'm not doing correctly. Any help will be welcome, thanks in advance!
Since TextPattern is a PHP-based CMS, I've tried to add
if ((isset($_SERVER["HTTP_ACCEPT"]) and
stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) or
stristr($_SERVER["HTTP_USER_AGENT"], "W3C_Validator") )
{
header("Content-type: application/xhtml+xml");
print("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
}
else
{
header("Content-type: text/html; charset=utf-8");
}
at the beginning of my index.php (as stated in several pages I've seen), what will make my page be served as "application/xhtml+xml" to web browsers that support it, and "text/html" to the ones that don't (mainly IE). Anyway, I can't get it to work, and since I have no idea on PHP, I'm not sure about what I'm not doing well.
My index.php is:
<?php
/*
$HeadURL: http://svn.textpattern.com/development/4.0/index.php $
$LastChangedRevision: 804 $
*/
// Make sure we display all errors that occur during initialization
error_reporting(E_ALL);
@ini_set("display_errors","1");
if (@ini_get('register_globals'))
foreach ( $_REQUEST as $name => $value )
unset($$name);
define("txpinterface", "public");
// Use buffering to ensure bogus whitespace in config.php is ignored
ob_start(NULL, 2048);
$here = dirname(__FILE__);
include './textpattern/config.php';
ob_end_clean();
if (!isset($txpcfg['txpath']) ) {
header('Status: 503 Service Unavailable'); header('HTTP/1.0 503 Service Unavailable');
exit('config.php is not ok or not found. If you would like to install, go to [/subdir]/textpattern/setup/');
}
include $txpcfg['txpath'].'/publish.php';
textpattern();
?>
and the beginning of the content of my page that I typed using TextPattern is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head>
<base href="<txp:link_to_home />" />
<link rel="stylesheet" href="<txp:css />" type="text/css" media="screen" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8" />
I'm giving all this information because I'm not sure about where's what I'm not doing correctly. Any help will be welcome, thanks in advance!