b2evolution Base Tag Issue

b2evolution uses a base tag to help with its template system. This is fine in modern browsers but depending on how the base tag is written IE6 may refuse to show the site at all, even going to the point of giving the user a popup warning dialogue. The fix is quite simple and I’ve implemented it in the past for both Joomla and CMS Made Simple. Now it’s time for the b2evolution version.

The following is for b2evolution v 3.3.3 and requires changing the file “inc/_core/_template.funcs.php”. After making a backup of the file, open the original and find the “base_tag” function. For me it looks like the following as default:

function base_tag($url, $target = NULL)
{
    global $base_tag_set;
    $base_tag_set = $url;
    echo '<base href="'.$url.'"';
    if(!empty($target)) {
        echo ' target="'.$target.'"';
    }
    echo " />n";
}

Change that to the following to allow the base tag to work with IE6:

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

    $result = '<base href="' . $url . '"';
    if (!empty($target)) {
        $result .= ' target="' . $target . '"';
    }

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

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

    echo $result;
}

Voila! Your b2evolution blog is now viewable within IE6. Easy.

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.

I come from the Net – through systems, peoples, and cities – to this place: MAINFRAME. My format: Guardian. To mend and defend – to defend my new found friends, their hopes and dreams, and to defend them from their enemies. They say The User lives outside the Net and inputs games for pleasure. No one knows for sure, but I intend to find out. ReBoot!

— Bob, ReBoot