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.

We have known each other many years, but this is the first time you’ve come to me for counsel or for help. I can’t remember the last time you invited me to your house for a cup of coffee, even though my wife is godmother to your only child. But let’s be frank here. You never wanted my friendship. And you feared to be in my debt

— Don Corleone