Joomla and SWFObject IE6 Base Tag Issue Revisited

A while ago I wrote this post about how to get Joomla working with swfobject due to the base tag issue (swfobject FAQ Point #4). At some point Joomla has had what seems like a major rewrite and I found after a recent upgrade to 2.4.6 that the base tag issue is back again. To tell the truth I wasn’t that happy with my last attempt but I also switched to using CMS Made Simpler instead of Joomla for most projects so haven’t had the chance to revisit it. Seems like now is the time. The fix is simple and is based on one that I wrote for CMS Made Simple which in turn is based on one that someone wrote for Drupal.

Navigate to the Joomla root directory, then open /inc/_core/template.funcs.php. Search for “function base_tag” which for me is on line 307 and then replace the entire function with:

function base_tag($url, $target = null)
{
    global $base_tag_set;
    $base_tag_set = true;

    //Taken from a fix for Drupal - http://drupal.org/node/285255
    $browser = $_SERVER['HTTP_USER_AGENT'];
    $result = '';

    if (!empty($target)) {
        if ($msie = strpos($browser, "MSIE")) {
            if (substr($browser, $msie + 5, 3) < 7.0) {
                $result .= $url . '"target="' . $target . '">' . "n";
            } else {
                $result .= $url . '"target="' . $target . '"/>' . "n";
            }
        } else {
            $result .= $url . '"target="' . $target . '"/>' . "n";
        }
    } else {
        if ($msie = strpos($browser, "MSIE")) {
            if (substr($browser, $msie + 5, 3) < 7.0) {
                $result .= $url . '">' . "n";
            } else {
                $result .= $url . '"/>' . "n";
            }
        } else {
            $result .= $url . '"/>' . "n";
        }
    }

    echo $result;
}
Share Article

Comments: None so far...be the first!

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.

Come anonymously and leave nothing behind.

— The Water Margins