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.

You’re in a desert, walking along in the sand when all of a sudden you look down and see a tortoise, Leon. It’s crawling toward you. You reach down and you flip the tortoise over on its back, Leon. The tortoise lays on its back, its belly baking in the hot sun, beating its legs trying to turn itself over but it can’t. Not without your help. But you’re not helping. I mean you’re not helping! Why is that, Leon?

— Holden, Blade Runner