CMS Made Simple Base Tag Issue

Yet another opensource system that makes use of the HTML base tag as a hard-coded feature. Why is that a problem? Well if you use SWF Object to output the relevent HTML code necessary to display a Adobe SWF file on your page then you’ll be in for a surprise on IE6. You will get a popup prompt that states “Operation Aborted” for each SWF file on the page. Then once the page actually loads none of the SWF content is visible. Sucks. They detail a simple fix in the FAQ that uses IE conditional tags to add the required closing base tag which doesn’t solve the problem here. Their solution assumes you don’t need a self closing tag as default, for when it is not IE as the browser. That in turn leads to XHTML validation errors. The cheat is to write the conditional in PHP instead.

It’s a short fix to implement this in CMS Made Simple. Open /plugins/functions.metadata.php, starting at line #42 for me reads:

if ($showbase)
{
$result .= “n<base href=””.$config[‘root_url’].”/” />n”;
}

Change that to:

if ($showbase)
{
// Taken from a fix for Drupal – http://drupal.org/node/285255
$browser = $_SERVER[‘HTTP_USER_AGENT’];

if($msie = strpos($browser, “MSIE”))
{
if(substr($browser, $msie + 5, 3) < 7.0)
{
$result .= “n<base href=””.$config[‘root_url’].”/”></base>n”;
}
else
{
$result .= “n<base href=””.$config[‘root_url’].”/” />n”;
}
}
else
{
$result .= “n<base href=””.$config[‘root_url’].”/” />n”;
}
}

Then re-upload it. Now, whenever you use a {metadata} tag in a page template to get a base tag then you’ll always get a valid base tag. Why would you need to use the metadata tag? Well if you enable mod_rewrite support in CMS MS then you’ll need the base tag otherwise browsers will end up looking for your stylesheets in none existant directories.

Comments: 3

Leave a reply

Your email address will not be published. Required fields are marked *

God didn’t make Rambo, I made him!

— Trautman