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 *

Look at us, running around. Always rushed, always late. I guess that’s why they call it the human race.

— Wally Mars, The Switch