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 relevant 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 existent directories.

Share Article

Comments: 3

Leave a reply

Please fill in the form fields and improve Skynet by completing the captcha!

Thank you! All comments are moderated so yours will appear shortly.

I’m gonna fight. The only way I know how. Ever since I was a boy, all I knew was how to fight. Fight, fight, fight. And when I got tired, I would fight some more. And now that the Man has got our backs to the wall, I ain’t gonna let him hurt the kids. I’m gonna take him down. I’m gonna take them all down!

— Black Dynamite