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:

PHP:

  function base_tag$url$target NULL )
  {
     global $base_tag_set;
   
     $base_tag_set true;
   
     // Taken from a fix for Drupal - <a href="http://drupal.org/node/285255">http://drupal.org/node/285255</a>
     $browser $_SERVER['HTTP_USER_AGENT'];
     $result '';
   
     if(!empty($target))
        {
           if($msie strpos($browser"MSIE"))
              {
                 if(substr($browser$msie 53) < 7.0)
                    {
                       $result .='<base href="'.$url.'" target="'.$target.'"></base>'."n";
                    }
                 else
                    {
                       $result .= '<base href="'.$url.'" target="'.$target.'"/>'."n";
                    }
              }
           else
              {
                 $result .= '<base href="'.$url.'" target="'.$target.'"/>'."n";
              }
        }
     else
        {
           if($msie strpos($browser"MSIE"))
              {
                 if(substr($browser$msie 53) < 7.0)
                    {
                       $result .= '<base href="'.$url.'"></base>'."n";
                    }
                 else
                    {
                       $result .= '<base href="'.$url.'" />'."n";
                    }
              }
           else
              {
                 $result .= '<base href="'.$url.'" />'."n";
              }
        }
   
     echo $result;
  }
Comments: None so far...be the first!

Leave a reply

Your email address will not be published. Required fields are marked *

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